Connected Lab Power Supply: ESP8266 and Arduino Programing

REST API White Board

Hey and thanks for following my internet connected power supply unit project. This is an update to a previous post about the high level design for the project. If you are interested in that you can check it out here.

Since last week there has been a few changes to the board design. We have decided to switch from I2C to SPI because of the increase in speed and ease of programming. I also started the programming and found a few issues with the ESP8266 that I was hoping someone could help me clear up. But lets get to it!

The Programming Board

Currently I am prototyping all of this on a small breadboard because my big one is covered in the rest of the power supply components. As of now I am programming my arduino Uno to substitute what will later become a atmega328 surface mount chip. There is also a ESP-1 with a programming and reset button, and an USB-TTL connection. Our goal is to program both of these directly on the finished board so I woke up early this morning to furiously put a system that would work in fritzing.

 

Connected PSU programming board

In addition to the Atmega and ESP-1 I have included a logic level converter to safely transmit from the arduino 5V Serial signal to the 3.3V ESP8266 signal. Two DPDT switches to allow for the two chips to be programmed separately and also have the ability to communicate over serial. The rest of the communication for the SPI is not shown in this diagram, but I am hoping to get Jason to make a short post about the details of the switching power supply.

The Code

I got a very rough version 0.1 for both the Atmega and the ESP8266 up on github yesterday. The ESP-1 side works as a RESTful API that takes information from a client and sends it to the Atmega over serial. The ESP8266 also receives data about the state of the circuit over serial from the Atmega and all the requested information is sent back to the client. While all of this is going on the Atmega328 is controlling the rest of the board’s properties (voltage, current, limiting, and a frequency generator).

It would be nice if this would turn into a nice RESTful server library for the ESP8266. A lot of my other planned IoT projects could use this functionality. Once this project is done that and a few other useful functions will hopefully be developed and used by you guys who may like to get a hold of it.

Yea… it has some issues…

Everything I have right now is far from perfect. As of right now the REST API is able to send information back to the client but it does not have the ability to read JSON data from it yet. There are also inconsistencies in the data it returns. Sometimes it will give me two channels of data when I asked for just one, and sometimes it will include the 403 not found status code I have added when it gives me all of the information.

What I am most concerned about however is the transmission speed of the ESP8266. I have started using Postman to test my API, and it is recording the response time at just over a minute to send the data back. That transmission speed is about 300 kb/s, and that won’t fly if we are going to be controlling lab equipment. Perhaps somebody can take a look at the code on github and tell me if they know of anything that could solve this.