Porting AnalysIR firmware to Particle’s Photon platform

We have just completed porting our (single source) firmware from a range of other ‘Arduino’ type platforms to Particle’s Photon, having received it yesterday & thought it would be useful sharing some of our experiences for other ‘newbies’. The photon is one of a breed of modern IoT devices hitting the market at relatively low cost. It features a STM32F205 120Mhz ARM Cortex M3 processor running at 120MHz with 1MB flash, 128KB RAM and the all important WiFi. We have been wanting to support the previous Spark Core ($39), but couldn’t resist this little device at the low price point. Particle are also offering a similar embedded device in larger quantities of 10+,  for $12, including FCC certification.

Photon from Particle.io along with embedded sibling
Photon from Particle.io along with embedded sibling

Essentially, our firmware uses D2 & D3 on the Photon to read input from a pair of Infrared receivers to record signals and sends the data to our PC based AnalysIR (Infrared decoder and Analyzer) over serial @ 115,200 bps. We have been wanting to try out the Photon since it was announced last year, for $19+shipping.

The good news is that we have finally got it going after a few ‘road-blocks’ (self-inflicted) and it now seems to perform on a par with the other systems we support. At this time we are only using the cloud to update firmware on the device. Later, we will look at adding in a TCP/IP direct connection over LAN/WiFi, to replace the serial connection.

Photon from Particle.io is really small and comes in a matchbox
Photon from Particle.io is really small and comes in a matchbox

Hopefully some of this post will help others similarly starting out with the Photon.

OTA Flashing
This one resulted in the biggest ‘sink’ of our time. In our ‘loop()’ we always wrapped the actual code inside a while(true) loop to get the best performance, as Arduino does some extra processing at the end of each loop, which we don’t need. I suspect a similar approach on Photon meant that the OTA firmware requests were not being serviced (I presume this happens at the end of each loop by default [?]). As our first workaround, we placed a Spark.process() call every time thru the loop & although this allowed OTA firmware updates to work, we then started missing interrupts (maybe 25%+). The final solution came by doing 20 Spark.process() calls during the first 20 seconds in Setup and then issuing a Spark.disconnect (to turn off the cloud connection), which was enough time to allow an OTA update after reset. There may be more elegant solutions, but this approach is sufficient to meet our needs for now.

Interrupts
Currently, interrupts are not working on some pins on the Photon, but we are OK as we just need 2 – on pins D2 & D3. Our initial mistake here was using 0 & 1 (à la Arduino INT0 & INT1) as the interrupt pins. Once we got some assurance on the forum that interrupts were indeed working, we quickly figured out our mistake and used D2 & D3 as the pins in the attachInterrupt call. A search on the forum will show which pins can be used at present & the plans for a fix for the other pins. The interrupts in our configuration can fire as often as every 17 uSecs when an IR signal is being received and we noticed that when the cloud was connected, the timings recorded were off a bit, occasionally. Now that we disconnect the cloud after the OTA ‘window’ during setup – the timings recorded are ‘spot on’ every time.

General Code & Getting Started
Clearly the Photon is a very different from a standard Arduino or Teensy etc. etc. However, our code ported well to the Photon environment with minimal changes. Most of the issues we encountered were related to OTA & Cloud connections, which is to be expected. I guess a dose of RTFM will always help. There sure seems to be a lot of info available.

Conclusion
The next step is to get a few of our users to test it all out using their Photon and then later to get a direct network connection going to replace the current serial connection.. All in all, we managed to port our code with only a few extra lines of code (for OTA & cloud disconnect) & no material changes to our core Arduino code – nice.

Try it out
Existing users of AnalysIR can try out this new Photon firmware by emailing us. Currently, we have no plans to support the Spark/particle core platform, but the firmware should be similar, for anyone who wants to try it out. Just email us directly, to get a preview of the firmware.

Simple Infrared PWM on Arduino, Part 2- RAW IR Signals

In Part 1 of this series, we demonstrated how to send signals using simple Infrared PWM on Arduino. In this Part 2 post we look at sending RAW IR signals – specifically a RAW NEC signal and a longer RAW Mitsubishi Air Conditioner signal. We have also improved the method shown in Part 1 due to some issues we identified when sending ‘real’ signals versus the ‘test’ signal we used before. (More on that later). In Part 3, we will take the signals from this post and show how to send them using their binary (or Hex) representation, which saves lots of SRAM.

Original NEC 32-bit and Mitsubishi 88-bit Signals displayed using AnalysIR
Original NEC 32-bit and Mitsubishi 88-bit Signals displayed using AnalysIR

Continue reading Simple Infrared PWM on Arduino, Part 2- RAW IR Signals

Simple Infrared PWM on Arduino

We are often asked on discussion boards, about conflicts between IRremote or IRLib and other Arduino Libraries. In this post, we present a sketch for ‘Simple Infrared PWM on Arduino’. This is the first part in a 3 part series of posts. Part 1 shows how to generate the simple Infrared carrier frequency on Arduino, using any available IO pin and without conflicting with other libraries. Part 2 will show how to send a RAW infrared signal using this approach and Part 3 will show how to send a common NEC signal from the binary or HEX value.

Example 56kHz generated Infrared signal @ 50% duty cycle
Example 56kHz generated Infrared signal @ 50% duty cycle

Continue reading Simple Infrared PWM on Arduino

Latest release of AnalysIR V1 preview #2 is now available for download

Dublin, Ireland – 17th April 2015. We are happy to announce the latest release of AnalysIR V1 preview #2 is now available for download by our backers & supporters. Existing users of AnalysIR will receive an email with instructions on how to download this version. New users will receive the details as part of the registration process.

AnalysIR Screenshot
AnalysIR Screenshot

A major highlight of this release is full AnalysIR support for our soon to be released LearnIR (IR Learner). LearnIR delivers the best performance available for receiving and sending Infrared signals with excellent accuracy.

View the AnalysIR Product Sheet(PDF)

We would like to extend a big thanks to the many users around the world who have helped with feature requests, new protocols and testing over the last months.

Some Highlights in this latest release include:

Continue reading Latest release of AnalysIR V1 preview #2 is now available for download

AnalysIR now decodes over 60 Infrared Protocols

We have been updating the AnalysIR documentation for the upcoming 1.0 release and realised that AnalysIR now decodes over 60 Infrared protocols. Wow!. Along with the most common TV & media remotes controls there are 25 Air Conditioner protocols included. The full set of protocols is included with the latest ‘dev’ release, which is available to all current & new owners of AnalysIR (less the aforementioned documentation) in advance of the  pending 1.0 release. The 1.0 release will incorporate over 200 new features, updates and fixes compared to the initial release and also supports our new IR Learner which will be launched along with a range of MakeIR Infrared kits in the coming months.

Over 40 Infrared ProtocRols supported by AnalysIR
Over 60 Infrared Protocols supported by AnalysIR

Here is the latest list of Infrared protocols supported by AnalysIR. Continue reading AnalysIR now decodes over 60 Infrared Protocols

Reverse engineering the Mitsubishi AC Infrared protocol

This post is the second in a two-part series about Reverse Engineering AC Infrared protocols. This time we look at the Mitsubishi Air Conditioner IR Protocol. The project was undertaken by  two of our users in France (Vincent & Mathieu), with the help of AnalysIR, who  collaborated to reverse engineer this Mitsubishi and previously the Panasonic AC Infrared protocol, both examples of the more challenging AC Infrared protocols. Not only did they identify the individual field codes & checksum but also provided some impressive documentation. Detailed information is available via GitHub which is linked below. This 288 data bit Mitsubishi AC Infrared protocol is composed of two consecutive frames. Both frames are always identical for each signal sent. In common with most AC units the complete settings are sent with every IR signal (temperature, fan, swing etc…). AnalysIR was used to record and turn the signal into HEX/Binary format from which the reverse engineering of the individual fields was tackled.

Mitsubishi AC AnalysIR Screenshot
Mitsubishi AC AnalysIR Screenshot

Continue reading Reverse engineering the Mitsubishi AC Infrared protocol

Reverse engineering the Panasonic AC Infrared protocol

Recently, two of our users in France (Vincent & Mathieu) collaborated to reverse engineer the Panasonic AC Infrared protocol, one of the more challenging AC Infrared protocols using AnalysIR. Not only did they identify the codes & checksum but also provided some impressive documentation and full source code to help others. Detailed information is available via GitHub which is linked below. This 216 data bit Panasonic AC Infrared protocol is composed of two consecutive frames. The first frame remains constant for every command sent to the AC unit. In common with most AC units the complete configuration is sent with every IR signal (temperature, fan, swing etc…). AnalysIR was used to record and turn the signal into HEX/Binary format from which the reverse engineering of the individual fields was tackled.

AnalysIR - Panasonic AC 216 bit Infrared signal
AnalysIR – Panasonic AC 216 bit Infrared signal

Continue reading Reverse engineering the Panasonic AC Infrared protocol

Infrared receiver showdown – TSOP34438 vs VS1838B winner revealed

Having helped many makers resolve problems with Infrared remote control projects over on the Arduino forum, we decided to put 2 of the more common 38kHz receivers, TSOP34438 vs VS1838B,  ‘head-to-head’ over 3 rounds in a winner takes all contest. Different people report a wide variety of problems when first attempting infrared remote control, resulting from using the wrong receiver to timer or interrupt conflicts between the various libraries available. Our commentary on the ‘face-off’ will hopefully shed some light on the ability of these 2 common Infrared receivers to deliver results, as expected.

Idle Interference on VS1838B
Idle Interference on VS1838B

Continue reading Infrared receiver showdown – TSOP34438 vs VS1838B winner revealed

AnalysIR supports PSOC 4 from Cypress

AnalysIR now provides support for the PSOC 4 Prototyping kit from Cypress. Effective immediately users of AnalysIR can use the kit to act as an Infrared source for AnalysIR. The PSOC 4 Prototyping kits are available from Cypress and via their global distributors for just US$4 plus shipping. To use the kit with AnalysIR you will also need an IR Receiver and an optional IR Learner, which can also be purchased with AnalysIR. Initially, the PSOC Firmware is available on request and will be included as part of the installation package in a future release.

PSOC4 and AnalysIR
PSOC4 and AnalysIR

Continue reading AnalysIR supports PSOC 4 from Cypress

Preview: DetectIR, advanced infrared receiver

The fourth member of our MakeIR series of devices & kits will be DetectIR. This infrared receiver module can be configured for Visual IR signal detection, Serial over IR or as an Infrared receiver which can handle even the longest Air conditioner signals. DetectIR is built with only the highest quality IR components available.

DetectIR block diagram
DetectIR block diagram

We have provided a link below to the preliminary product data sheet and would welcome feedback on additional, nice to have or missing features, if any. Please read the datasheet for a more detailed description of DetectIR. Continue reading Preview: DetectIR, advanced infrared receiver