Power Monitoring Code

Power Monitoring Code

There are two chips that make up this board – the Teensy 3.2 and the ESP8266. The ESP8266 in this setup runs the AT firmware, which allows communication over serial using a published API. The API documentation is available here. To flash the ESP8266 with the AT firmware, Expressif (the manufacturer) has a tool available on their website.

The default baud rate of the most recent AT firmware is 115200. This can be changed, but the faster the better, right?

To use the Arduino IDE to program the Teensy 3.2, you can download Teensyduino, available from here.

So now our environment for programming this combo is ready!

To test the connection between the ESP8266 and the Teensy 3.2, you can throw on a simple passthrough sketch, and manually type in AT commands into the serial monitor. (also for some reason I can’t figure out the WordPress code formatting)


void loop() {
// Send bytes from ESP8266 -> Teensy -> Computer
if ( Serial1.available() ) {
Serial.write( Serial1.read() );
// Send bytes from Computer -> Teensy -> ESP8266
if ( Serial.available() ) {
Serial1.write( Serial.read() );

Make sure you put initialize both serial ports to 115200 in setup().

The complete code is available at https://github.com/fillycheezstake/PowerMonitor. It’s a WIP, so don’t judge too hard.