Close

AVR SPI Slave

A project log for Secure ESP8266 MQTT p.o.c.

Secure ESP8266 MQTT proof of concept

W. TaylorW. Taylor 02/07/2019 at 18:320 Comments

AVR SPI Slave

Copyright (c) 2019 Warren Taylor.

Disclaimer

The following documentation in no way guarantees a secure system.

Overview

The original plan was to connect peripherals directly to the ESP8266 data pins but I ran out of pins very quickly. Since I had an unused ATmega168 lying around I though "what the heck" and connected the two chips via SPI with the ESP8266 as the master and the ATmega as the slave. In additions to providing a larger number of data pins this scheme also provided 5v tolerance.

This AVR SPI Slave simply receives a byte value from the controlling ESP8266 and then sets the output of Port D to this by value. In other words the ESP8266 is setting the eight Port D output pins via SPI. That's all.

However, a huge advantage for the future is that with a bit more programming in the ESP8266 the AVR can be programmed Over-the-Air, which means it can be made to do anything.

This in not an Arduino Sketch. This is very simple native AVR firmware. Why? Because I didn't know how easy native AVR programming was until I tried it.

The source for this project can be found at https://github.com/tsi-software/Secure_ESP8266_MQTT_poc

Requirements

Wiring up the AVR

I’m going to defer to two other web sites that do an excellent job of describing how to wire-up and program the AVR.

Programming the AVR

Connect you development computer to the ATmega168 as described above. Then, from this "avr_spi_slave" directory, run:

make program_fuses
make program

Note: "make program_fuses" only needs to be run once, not each time the source file changes.

AVR References

Discussions