Monday, June 27, 2016

Maker Faire Singapore 2016

Maker Faire Singapore 2016

Efforts in Maker community and education recognized by Singapore Ministers.  

24Jun16, Received 
“Certificate of Recognition for 5 years of continuous support & enthusiasm” from Dr. Vivian Balakrishnan Minister of Foreign Affairs.

25Jun16 Received “Certificate of Appreciation” from Dr. Yaacob Ibrahim Minister of Communications and Information

Wednesday, June 22, 2016

Fab Lab Fab Academy Final Project Software Defined Cooking with ESP8266

Fab Lab Fab Academy Final Project Software Defined Cooking with ESP8266

Software Defined Cooking with ESP8266

There is an idiom: the proof of the pudding is in eating it. Same applies to the successful implementation of Software Defined Cooking with ESP8266; the proof is in the egg and eating it. 

The objective of this final project to be submitted in due course for completion of Fab Academy 2016 is to design and fabricate an apparatus that display & control the temperature of a heated water bath (Sous Vide) over the Internet. DS18B20 acquire the temperature of the water bath, ESP8266 send this data via HTTP to thingspeak, and via MQTT to Node-Red server hosted on Cloud or VM. PID controller is defined in Node-Red with a set point. Output of PID is send via MQTT to ESP8266 to control the CPC1966B connected with heater.

Background

Ever since humans discovered fire to cook food. The desire to have tasty food hot, and ready to serve without significant labour contributed to the preparation is insatiable. Progressively over different period of time, the labour required to prepare food is contracted to another person whether specialized or otherwise. By logical extension of the idea of the labour is contracted out to prepare food for humans, here comes the robot cook. Hence the notion of Software Defined Cooking meant for robots or home appliances have to be defined. An industry framework is needed to define protocols, communication standards, recipe, dispensing of food items, quality assurance and etc for Software Defined Cooking. Through observations on demonstrations in CES over the years, the software defined cooking appliances meant for smart kitchens are implemented in product silos by the respective vendors. Appliances that do not interact with other makes of smart appliances, and human owners are nothing close to the ideals of a Software Defined Cooking. 

Some vendors have disrupted the market by inventing heating mechanism meant for cooking that is controllable by software. FreeScale have invented a “solid-state, high-power output, high-operating temperature radio frequency (RF) transmitter technology” to address software defined cooking. This articlehere explains the FreeScale RF solution and addresses the following issues: 
1. “Heating is difficult to control with both thermal (heat) and temporal (time) precision. Heating elements take time to heat, are frequently not calibrated to a precisely measured numeric temperature scale, and then take time to cool to lower temperatures.”; 
2. “It is extremely difficult to track the “doneness” state of the inside of food with precision.” 
3. “The feedback loop between sensing doneness and adjusting temperature has been performed mostly by human observation, judgement and labor throughout recorded human history.” 

The article above also outline three features of a Software Defined products 
A. “Gather and analyze sensor data.” 
B. ”Maintain peak performance and health based on sensor data analysis (feedback loop).” 
C. “Communicate their analysis with other software-define products and cloud services for continuous improvement.” Besides the highlights of the 3 issues and 3 features, the article mentioned above and the product video of RFSage, an innovative appliance utilizing the FreeScale RF technology did not communicate enough details for a layman to deduce whether the RF mentioned is used for both transferring heat and communicating cooking data between different make of smart appliances in the category of software defined cooking.

Proposal

A little more historical background. Back in 2011, I chanced upon sous vide while clicking away on cooking videos over the Internet, and saw a demo of thermal circulator in a chemistry lab, I have never looked back since. The essence of sous vide cooking is to maintain a water bath at precise temperature, with food placed in food safe bags submerged into this precise temperature controlled water bath. We started off with a store bought DIY kit that cost quite an arm and leg. We even went to the extent to make sous vide shield for Arduino. At that point in time, a dedicated sous vide supreme is out of the equation, it has to give way to tuition fee, rent, transport, and food. 

Sous vide solved two out of the three issues highlighted earlier. Doneness of the inside of the food is precise with sous vide, thus the inexperienced novice is spared from the labourious sensing doneness and adjusting temperature to prevent overcooking; hopefully stop food wasting from bad cooks. The other pressing issue is the calibration between heat transfer and time needed for heat to transfer is solved partially with some sous vide implementations. Some amateurish sous vide controller uses “bang-bang” algorithm for open feedback loop system, which is bad, really bad and hardly precise at the required set point. Some comes with PID controller, in which a controller for continuously adjusting the heat and time components in a closed feedback loop system. 

The three features mentioned above speaks of the cloud computing itself without mentioning the name. A server in the cloud will collect and collate information send by the sensors, perform computations on the data collected, transmit control to the actuators, and lastly communicate to user through the use of visualizations. 

Full implementation here: http://archive.fabacademy.org/archives/2016/fablabsingapore/students/100/project04.html

Friday, January 22, 2016

Fab Academy16


http://cba.mit.edu/events/03.05.fablab/fablab-dyd02.pdf  "This paper presents the composition and the rationale behind the creation of a network of fabrication laboratories, FAB LABs, whose mission is to provide concrete examples that would lay the foundation for a new framework for this reconceptualization. "




weekly builds and guides at http://archive.fabacademy.org/archives/2016/fablabsingapore/students/100/index.html

Saturday, January 2, 2016

Sous Vide sur Internet: Node-RED, MQTT, ESP8266

Sous Vide sur Internet: Node-RED, MQTT, ESP8266

Cooking over the Internet has always been my pet peeve. That is when I could marry two of my best loves, maybe into a product that pays. Sous Vide sur Internet, is in French, loosely translated to sous vide over the Internet. well, it doesn't takes much of my agar-logic to get the translation.

Just a little bit of trivia:
Back in 2010, 2 of my padawans are working on a Final Year Project making a web2.0 smart fridge that tracks item in the fridge by QR code follow by suggesting a youtube cooking video based on the items in the smart fridge. When DIY Sous Vide is all the rage on the Internet, I have my own fair share of experiments with sous vide with a myriad of implementations. Back in 2012, one of my padawans took it up the challenge to build a sous vide shield for arduino http://shin-ajaran.blogspot.sg/2012/12/coming-to-end-of-2012.html.

Fast forward to 2016, The notion of Internet Enabling dumb devices aka household appliances is all in the rage. The release of ESP8266, a very cheap (USD4 at Dec2014) WiFi enabled microcontroller has kick start a whole plethora of IoT devices fuelling the development of devices once seem dumb. The Maker's IoT Kit and the detail step by step guide on how to use ESP8266, maker IoT Kit break out board with arduino IDE located here http://shin-ajaran.blogspot.sg/2015/11/makers-iot-kit-for-esp8266-esp-01.html is one such enabler to make dumb terminals smart by connecting to the Internet.

Having the ESP8266, the Maker's IoT Kit for ESP8266 is only one third of the whole picture of the end to end IoT solution.

The complete end to end IoT solution will have 3 parts,
1. the Internet Enabled device with sensors
2. the computing and data aggregation platform aka cloud computing
3. the visualization over the Internet

Earlier, the Internet Enabled sensor was addressed in this post in detail http://shin-ajaran.blogspot.sg/2015/11/makers-iot-kit-for-esp8266-esp-01.html. The visualization of data was addressed in an earlier post too http://shin-ajaran.blogspot.sg/2015/09/stream-iot-sensor-data-esp8266-nodemcu.html, via thingspeak.

The computing and data aggregation platform is the gist of this guide. In the earlier post, the protocol of chose to stream data is via HTTP. There are pros & cons associated with this protocol in the implementation of IoT end to end solution, this post is not going to delve deep into the discussion of it. Assuming there are 1000000 IoT devices, quite chatty (in terms of data transmission) talking to a data aggregation server (assume to have 1 server in this discussion) concurrently via HTTP. The server might run into a resource squeeze after N-th connection. Hence MQTT comes to the rescue. MQTT is an "archaic" protocol (invented in 1999 by scientist working for IBM), partially revived by engineers working in Facebook for the real-time messaging function https://www.facebook.com/notes/facebook-engineering/building-facebook-messenger/10150259350998920/ .  MQTT follows a PubSub model, where sensors subscribed to a "topic" to listen to control command or publish to a "topic" to stream data to the data aggregation server.

In this guide, several software components are needed, on top of the hardware component Maker's IoT Kit for ESP8266.

Software needed
1. Ubuntu Server 14.04 on a physical computer or virtual machine on the cloud
2. MQTT protocol, the broker used here is mosquito MQTT http://mosquitto.org/
3. Node-RED as the data aggregation platform http://nodered.org/

The instructions to install the software on ubuntu is at the footer of this guide.

In the diagram above, the putty window on the right is the MQTT client, publishing data "data2" to the MQTT broker which is the putty window on the left. Node-RED is in the background, capturing the data transmission from MQTT client and MQTT broker, and it gives a visual on the "wiring" of the end to end IoT solution,

The Diagram follows the same arrangement as the previous, but with the addition of an ESP8266 enabled with temperature sensor to stream temperature data to thingspeak via HTTP, and to Node-RED via MQTT. We now have an end to end IoT Solution. but wait, it is unidirectional. the data only travels from the IoT sensor to the data aggregation server, but not the other way round. control needs to be issued from a server, just to complete the bidirectional communication possibly for an IoT solution.
Setting up the corresponding MQTT broker on Node-RED is very easy. simply drag the MQTT icon from the left hand side, and place it in the "canvas". edit the MQTT broker parameters accordingly.

Node-RED provides a visualization of IoT device, data aggregation, and it's connection, MQTT would function too. The above diagram describes the MQTT broker and the MQTT client in action.
The diagram above describes the Node-Red in operation, and the step by step guide to install additional "nodes" aka functionality to Node-Red
The diagram above describes the successful addition of a PID controller for Node-RED.
Are you thinking of what i am thinking? YES, cooking sous vide over Internet!! IoT sensor send the temperature of the cooking to Node-Red via MQTT. The computation of the PID based on the receive temperature data and the set point is offloaded from the ESP8266 to the Node-RED that is hosted on a virtual machine with much more muscle power as compared relatively. The delta, i.e turning on the heating element is the command to be sent from the computing platform to the ESP8266 IoT sensor that controls the relay. 

The source code for the ESP8266 temperature control and relay control is available at the footer. The above diagram describes the detail of the upload.



The above diagram describes the wiring of the Maker's IoT kit for ESP8266 to a multiplug modified with a solid state relay. The step by step guide of making the SSR plug is here http://shin-ajaran.blogspot.sg/2014/11/iot-inspired-multi-plug-modified-with.html or here http://www.instructables.com/id/IoT-inspired-multiplug-using-SSR/

The following diagrams describe the testing of the Sous Vide over Internet setup with Maker's IoT Kit for ESP8266, MQTT, and Node-RED 
data aggregation and computation on Node-RED, data visualization on thingspeak
testing of the set point at 30degC

tuning parameters for PID
comparing the data output on serial from ESP8266, and Node-RED


asasdfa
ESP8266 MQTT and ThingSpeak code here:

Node-RED setup here: 










Thursday, December 24, 2015

Beginner's ESP32 guide to getting started

Beginner's ESP32 guide to getting started


Yours truly is one of the lucky 200 to receive an ESP32 for beta testing. The neat little package came few days before Christmas. indeed, Christmas came early! It is a tough call, wrestling with the decision to roast the bird for Christmas eve dinner or to explore the ESP32. The latter won! we shall have chinese takeaways for dinner later.

A little bit of trivia. Back in June15 at MakerFaire Shenzhen, yours truly was sitting in the same row with the real mccoy https://twitter.com/ceo_espressif whom created the ESP8266, listening to the real arduino https://twitter.com/mbanzi giving a keynote on the yet to be released Genuino, and not forgetting yours truly getting his paws on the newly released nodeMCU v1.0 (black) http://shin-ajaran.blogspot.sg/2015/09/stream-iot-... from "zhao zhong 赵总" at a very competitive price.

ESP32 was featured on MAKE, Hackaday, and Adafruit. Do check the reference section for the details. Conventional wisdom assumes ESP32 is going to supersede the hugely successful ESP8266 for IoT application. But yours truly begs to differ. ESP8266 is targeted at the "everything" market, where gazilllions of IoT enabled sensors aka "throwies" are deployed to form an ubiquitous computing framework to collect data on just about anything! A plethora of boards manufacturer have utilized the ESP8266 in their respective iteration of IoT with cloud offerings. Hence the "everything". The ESP32 sports much bigger processing power, more RAM, and most importantly encryption at hardware level. Perfect timing to address the insecurities in the IoT devices sending data in clear text over the network via http or mqtt. ESP8266 is going for USD4 (got it for SGD9 at 2014). Unfortunately, the users (yours truly included) do not have the slightest hint on the price for the ESP32.

Below is a quick summary of the ESP32

Faster WiFi: Wifi has been upgraded to support HT40 speed (150 Mbps)
Bluetooth Low Energy (BLE) and Classic Bluetooth
Dual processor: 2x Tensilica L108 processors clocked at up to 160 MHz
Low Power Mode: deep sleep, etc.....
IO: Capacitive touch, ADCs, DACs, I2C. UART, SPI, SDIO, I2S, RMII, PMW
RAM: 400 KB on-chip RAM
Security for IoT: Hardware accelerated AES and SSL, etc

If you could recall about a year or so when ESP8266 was first released, the lack of proper, consistent, and precise documentation in the English Language has led to many frustrations among the early adopters. Great progress we have witnessed in 2015 for the developments of the ESP83266 by the members of this community. Makers alike, yours truly paid his due diligence in sharing a how-to guide on instructables http://www.instructables.com/id/noobs-guide-to-ESP... to address the inconsistency. This time round with ESP32, the documentations are much better!! Sorry, could not share the documentations now due to confidentiality. Let's wait for the full release straight from the horse's mouth. IMHO the documentations can still be a steep learning curve for the beginner. Furthermore, the QFN -ish packaged ESP32 chip that is fully assembled on a breakout board sports a 1.27mm (50mils) spacing between the pins (pitch) on the supposedly breakout board. It is very intimidating to solder onto the other provided breakout board to make it breadboard friendly. A beta tester has reported on an unfortunate event of damaged ESP32 http://esp32.com/viewtopic.php?f=2&t=41. Another beta tester have used the solder paste + heat gun method https://harizanov.com/2015/12/esp32/

This i'ble is an ongoing process aims at addressing the following

0. prep the ESP32 breakout board for prototyping on a breadboard

1. initial powering up and observations

2. setting up of programming environment + hello world

3. references

Soldering the ESP32 breakout board




parts needed
1. a 200 DegC temperature regulated, very fine tip solder iron, and 0.4mm solder.

2. heat gun. optional. useful if need to remove solder for SMD re-soldering work

3. soldering wick

4. solder flux and applicator

5. PCB vice of some sort

check out the annotations in the picture for a visualization on items needed

methodology

1. Practice some surface mount soldering before committing. yours truly only have 1 eval unit and can't afford to screw it up. If you have soldered ESP-12 and it's breakout board, it is definitely good experience. HIghly recommended to do SMD soldering in a well lit work area.

2. The ESP32 break out board moves around easily on the breakout board for breadboard. A tape of some sort is used to secure it in place. Make sure the pins are aligned properly on the 3 sides. Perhaps some heatsink compound can be applied on the small square on the breakout board for breadboard, and then the ESP32 board aligned on it. The tackiness of the heatsink compound will help to make the ESP32 stay in place.

3. Always ensure the pins are perfectly aligned on the ESP32 board to the breakout board for breadboard that is secured with a PCB vice. Apply solder flux on the soldering surface. If you are right hander, positions the pins to be soldered to be on your right hand side, such that your soldering movement is moving towards the right, bring the melted 0.4mm solder perpendicularly away from the neighbouring pins. 1.27mm spacing can be quite nerve wrecking to solder, and the random thoughts of screwing up is so strong! stay focus!

4. start soldering from the ground pins. Refer to the pin out diagram, there are 3 of them, one on each side of the ESP32 breakout board, and located at a convenient corner. Speaking from yours truly own experience in soldering the ESP32, if one of these is screw up, still have 2 more to go :) Once the 3 ground pins are soldered, the ESP32 should be perfectly aligned and sits securely on the breakout board for breadboard.

5. repeat step3 until all pins are soldered

Examine the solder work


Examine the SMD soldering under a magnifying glass for dry joints. Excess solder is fine as long as it doesn't overflow to neighbouring pins. A smartphone camera with it's magnifying function works well too.

It is recommended to fix the dry joints with another round of soldering.

If there are excess solder onto the neighbouring joints, use the soldering wick and heat it up with the solder iron or hot air gun to remove the excess.

once satisfied with the SMD soldering work, continue to solder the PTH male header pins.

check out the pictures for details

Powering up the ESP32 with CP2102 for the first time





Parts needed

1. CP2102 or any USB to TTL device

2. jumper wires

methodology

1. connect 3V3 and GND from CP2102 to ESP32.

2. connect TX of CP2102 to RX of ESP32, and RX of CP2102 to TX of ESP32

3. EN pin on ESP32 left floating ---> update: check out the next step for wiring a reset button

4. plug in CP2102 to USB port of computer

Observations

At first light, only the CP2102 lights up. yours truly thought he is going to have a piece of bricked ESP32 for Christmas, the thought of it is already depressing. As compared to the ESP8266 that sports a blue and a red LED, The ESP32 does not have any lights to indicate activity??? Upon further probing, under the wireless network of his win8.1, the ESP32 network shows up. what a relief :)

Putty with the setting of 115200 8 N 1 no flowcontrol is used to monitor the serial output of the ESP32 via CP2102. The screenshot here is so much different from Martin's. Not sure why is this so at the moment of writing -> update: check out the next step for wiring a reset button.

Powering up the second time with a reset switch



continuing from the previous step, some modifications to it.

the EN pin on ESP32 is pull high with a 10K resistor, and then grounded via push button switch to reset the ESP32 if asserted. Using putty with the setting of 115200 8 N 1 and no flow control, the same output is acquire as per martin's blog, just by resetting the ESP32 using the newly added push button. refer to picture for the details.

Setting up minicom



yours truly decide to setup minicom on ubuntu14.10 hosted in a virtual machine. Perhaps there is some command can be issued to the ESP32 to give the same output as martin's.

check out the screenshots for the commands and observations.

Still not a single clue of the debug message on the serial comm. Time to RTFM in detail.

Setting up the software enviroment & hello world


place holder for future updates

quick update1: the installation of the cross tool keeps breaking on a u14.04 Server 64bit hosted in a VM on w8.1. still probing around the error messages displayed

quick update2: after fixing some broken dependencies, finally the *.bin are compiled successfully. check out the screenshots. Next, need to figure out what's the functionality of the *.bin compiled from the provided "project_template". Then decides whether to upload to the ESP32 or otherwise. Still finding a way to "backup" the out of the box *.bin in the ESP32. just as an insurance to recover from mistakes.

Reference
MAKE: http://makezine.com/2015/12/09/meet-esp32-new-big-...

Hackaday: https://hackaday.com/2015/12/23/the-esp32-beta-uni...

Adafruit: https://www.youtube.com/watch?v=HCGHb0OVz1s

Martin's : https://harizanov.com/2015/12/esp32/

also on Instructables http://www.instructables.com/id/Beginners-ESP32-Guide-to-Assembly-Testing/

Thank you

thank you for coming thus far.

special thanks to

espressif CEO & reps for the ESP32

Mr.Dorville for the loan of SMD rework soldering station.

Merry Christmas 201