Tag Archives: Photon WIFI IOT platform

Enter the Photon

The details

tmpF540Particle.IO have been trying to send me a Photon for as long as I can remember. This all started in the summer when I was in Spain. I was expecting the device to arrive and the Spanish postal authorities got hold of it. I don’t know if they thought it was a top secret time travel device but they sent me a form requesting proof of purchase, proof I was a company and other paperwork. So I told them that this was a sample with no value, I’m not a company and I had no paperwork I didn’t have the goods and I’d not placed an order). The unit had travelled all over the world and was now sitting in Madrid while someone made themselves important. Despite various attempts in English and Spanish by myself and others, they simply were not releasing this until they had my sock length and proof of existence. By the end I’m betting Particle.IO had wished they’d not bothered.

tmp5722However, here I am back in the UK for now and shortly after I arrived, a second unit arrived.. followed promptly by the one which was supposed to go to Spain. You have to wonder… 

Checking their website these come in at about $19 (which not doubt ends up as £19 in rip-off Britain – I’ve not checked). As always you can zoom in on these images. So opening the rather neat and tiny box, you find inside, the Photon. It has a micro-USB connector as well as reset and setup buttons.

The Difference

So, what differentiates this from say, something like an ESP-12 or similar boards? So this is a small WIFI-enabled controller, programmed in something that looks suspiciously like the Arduino language – this is course is deliberate to give it that familiar look and feel. But looks can be deceiving – this is a powerful ARM Cortex M3 processor with a Broadcom WIFI chip complete with on-board v3v3 power supply – oh and the design is open-source.

Pins include D0-D7, A0-A5, ADC, DAC and serial I/O an the unit supports battery operation. You get 1 MB Flash and 128KB RAM. There’s an RGB status LED (nice touch) and FreeRTOS is pre-installed. There is a softAP setup mode and the unit is FCC,CE and IC certified. There is an internal ceramic aerial and a connector for an external aerial. You also have SPI,I2C,I2S (whatever that is), CAN, USB and PWM.

 

tmp311C

There’s a VIN pin or you can supply power (3.6v – 5.5v) or via the USB Micro B connector. Power supply should be able to source 1A of current to be safe.

Here’s a neat thing – in one mode the unit can constantly switch between internal and external aerial to see which is the best signal – I like that. All the pins except A3and DAC are 5v tolerant – which is nice.

I’m not going to go through the fine detail as it is all on their website. https://docs.particle.io/datasheets/photon-datasheet/

Programming

I remember the hassle I had trying to get to know the ESP8266 at first. Chinese only documentation, then Chinglish documentation, a lot of vagueness (all solved now of course) – but here we have EXCELLENT documentation at least from the perspective of someone coming in from the cold.

When it comes to actually programming this device…. the WEB IDE is really very good.  Being me the very first thing I did when opening the pack was to plug the board into USB – and it started up with one blue constant light and a blue flashing light – a good indication that something is actually working.

With no previous experience I went off to the web IDE here. https://build.particle.io/signup

I provided my email and password and within seconds I had an IDE in my CHROME browser with an empty program looking remarkably like Arduino.

tmpD652

I noted an example to blink a LED and clicked on that. Like Arduino it created a personal copy of this for me to play with – I have to say – neat – but at this point I was wondering – how on earth is it going to know where my board is!! Sure enough when  I came to the button to FLASH the chip it came up with “ADD NEW DEVICE”.

The WIFI setup

I noted a reference to Android and a light went on – it probably has an ACCESS point. I grabbed my mobile and sure enough – I could see PHOTON_CQGE. I hate reading manuals and so dived straight in.

I went on the phone for any old web page thinking that a login page might appear but no – a normal web page popped up – somehow the phone knew I was being an idiot and transferred me back to my home WIFI.

The instructions in the IDE said to go get the PARTICLE APP on my phone – so I did and logged in using the same account password I’d used on the PC – it said “let’s get started” and the next thing I knew it was connected to the Particle and asking for my WIFI details.

I have to say the APP was VERY slick. It warned me the setup might take a minute. Well, it didn’t work so I tried again. That didn’t work.

The USB setup

I did remember reading something about USB – I was plugged into my PC and I started to wonder if the board was getting enough power. I plugged it into a USB hub instead. No difference. At the third attempt the APP crashed on my Samsung S4. I rebooted the Samsung and tried again. No joy. The very slick App was dead.

The website said not to worry and here was another way! For attempt 2 I plugged the Photon back into the PC (and thinks were going SO well).  I already had NODEJS on my Windows PC so I downloaded the device driver and installed it – doddle – worked first time.

I then opened up a command line window in Windows 10 and followed the instructions.

npm install -g particle-cli

That worked (I’m familiar with that command thanks to Node-Red and the PI – it’s a NODE installer. I’d say all of that took maybe a minute with no errors.

I typed “particle setup” at the command prompt.

No problem – login – it didn’t help that they used colours and I’d set the command line to have a white background – but that’s my fault.  Immediately the software knew I had a Particle.

The software asked me for the WIFI setup and I put that in – but no matter what I did… the Particle would not connect. My PC is hardwired so the software asked me if I wanted to enter details manually for the WIF – I did -  “Obtaining device information..” I could not get past this. I tried the second unit – identical issue.

The page here… https://docs.particle.io/guide/getting-started/connect/core/

says “If your device is not connecting – try troubleshooting here..

I was using channel 1 (the device does not support channels above 11 which seems odd.

I had a standard network with WPA2 security….

No matter what.. the device would not connect to my router.

Inspiration

I went back to WIFI setup on a hunch. I wondered if perhaps my phone was being rather too keen to switch back away from the Photon WIFI during setup or perhaps there was an issue with it.

I went back to the Android setup and just before entering the WIFI access point and password I checked which network my phone was using. Voila – it had switched back to my own network. I switched it back to the Photon’s own access point and quickly swapped apps to run the setup. It worked flawlessly. I now had a Photo device online.

Back to the PC

With the phone turned off and armed with a Photon minding it’s own business with power only going to it and a name which SHOULD now be available – I went back to my PC setup.  I assumed that if the APP could see the device when logged in – so could the PC web application. I adjusted the simple BLINK program to flash 5 times a second and hit the lightning indicator to FLASH the board.

As if by magic the board started flashing purple to program (the RGB LED is a REALLY good idea) and seconds later D7 was merrily flashing away at 5 times a second. GOOD START.

There is a “publish and subscribe” system which looks remarkably like MQTT – if this worked then I was thinking they might get some business out of me as I use MQTT extensively with my little ESP boards – but I suspect not at least I could not find anything to suggest that it was a configurable MQTT setup. For these to be useful to me, my Node-Red setup must be able to control the boards.

tmp9296WELL – don’t you know, there’s a node-red-contrib-particle node!!! So being the impatient type I went off and installed the relevant node in Node-Red. A set of 3 nodes appeared.

I flashed the example function “Web connected LED” which created a function called LED which toggles a LED on and off (the little blue one attached by default to D7), No problem.

Playing by ear, I dropped the Particle Function node onto my work area in Node-Red (running on a Pi)

The IDE gave me my ACCESS token and the address of their server… all very easy..

Apparently there are some limitations if you use your own server – and I think that needs resolving as I do NOT want to be relying on someone else’s server for my winter heating (or door locking for that matter)… the IDE also gave me the ID number of my device.  I took a guess – the function name – LED seems reasonable.

I stuck an INJECT node into the Particle function node- and pressed the button on the Inject node and … nothing – not a sausage. Then I realised that they didn’t really mean TOGGLE – you had to pass a parameter ON or OFF.

tmp867C

I pressed the buttons – nothing. Then I noticed that the access key I’d picked in the IDE was timed out – why would that be? Well, so I pressed for another access key and punched that into Node-RED. SUCCESS!! Node-Red and hence any of my gadgets can now control the Photon. But MQTT would be good…

A Node-Red trivial MQTT to Photon function is of course simple to implement – and so we have a NEW TOOL to add to my home control box. Ok, so an ESP-12 can control a LED – I will investigate further and see just what this device can do that perhaps might not be quite so simple on an ESP-12. I guess at this point it is all down to available examples and code. This will take more than a few minutes – possibly a job for the holidays.

Library Relevations

In the IDE there is a link to “libraries” which opens up a very comprehensive list of libraries indeed including Neopixel, Onewire, Dallas, OH…. OH… and MQTT!!!

It took me all of 5 minutes to take the example MQTT program, give it my own access details and have MQTT-SPY turning this thing on and off. MARVELOUS.

Roundup

Of course this is just a surface review. Questions to be asked? What happens if the access point goes down and comes back up? What if the access point isn’t on when the unit powers up – and appears 5 minutes later? Does the Photon recover every time? I learned the hard way that all of these things need to be tested when developing my ESP8266 code (which is bomb-proof). Watch out for more information when I take this little device a stage further.

The showstopper – UK

At this point with a couple of little niggles above… I’m impressed. Very nice.  But…

MY only gripe –  prices for this device in the UK – Farnell want £19.99 and on Ebay I’ve seen £24 –  At that price I’d say the device is too expensive.  At the Particle.IO store, the device is $19 all in – but wait for it – including shipping to the UK $40.20 -  so more for shipping than the cost of the unit itself – all in comes to £26 – that is just too much. A Node-MCU board which uses the ESP8266 – though not quite as easy as this to set up comes in at £9.92 including postage. Now, depending on what you need, price may not be an issue. There is no doubt the IDE and tools therein are good and so for beginners this is a great tool but if you’re going to fill the home or office with all sorts of control gadgets, at these prices it gets expensive.

 

 

 

 

 

 

 

 

Facebooktwittergoogle_pluspinterestlinkedin