James Ferguson
CE351
ATMega 328 Advanced Applications
10/15/2020

Introduction
The goal of this lab is to design an internet of things (IOT) device that records the temperature and uploads the data to ThingSpeak. The device should also have a user interface for changing Wi-Fi credentials. This project follows this lab manual by Dr. Li.

Methods
The device shown in Fig. 1 was built on a breadboard using two Arduino Nanos, an ESP8266 Wi-Fi module, an Adafruit SSD1306 display and a DS1820 temperature sensor. The two Arduino modules communicate over SPI. Three orange wires are used for user input by pulling either high or low. In the final PCB design these will be replaced by pushbuttons and pull-down resistors. For the breadboard version these where left out due to a lack of space. These three signals represent up, select, and down actions. For readability these will be referred to as buttons.


Fig. 1 The device on a breadboard. the left Arduino is the slave and the right is the master. The three orange wires on the left can be pulled high or low for user input.

Each Arduino runs a separate script. The Temperature Master Script manages user input, the display, and communicating with the sensor. The Temperature Slave Script manages all Wi-Fi communication. The device collects data while in the main mode (Fig. 2a) and uploads it to ThingSpeak. Pressing the select button stops data logging and brings up the menu (Fig. 2b). In this menu the user can select an option by using the up, down, and select buttons. Here you can return to the main mode, set the access point name, set the password and reconnect with a new access point. Selecting "AP" or "Paswrd" opens the editor (Fig. 2c). Using the up and down buttons allows the user to change the indicated character and pressing the select button moves the indicator to the next character. pressing the select button on the final character sends the text to the slave and returns the user to the menu. The maximum length and what characters can be used are configurable by changing constants in the master script.

(a) Main
(b) Menu
(c) Editor



Fig. 2 Images of the designed user interface.

Results
Fig. 3 shows the recorded data from the device in ThingSpeak.


Fig. 3 Data from the device shown in ThingSpeak.

Fig. 4 shows serial comunication between the slave and ESP8266. It shows the device connecting to an ap called "Guest", sending a datapoint, changing to an acces point called "test" and then sending another datapoint. The "Guest" access point is managed by fort lewis collage and the "test" access point is a android mobile hotspot. Both of these access points are unsecured.

AT+RST
AT
AT
AT+CWMODE=1
AT+CWJAP="Guest",""
AT+CWJAP="Guest",""
AT+CWJAP="Guest",""
AT+CIPMUX=1
AT+CIPSTART=0,"TCP","api.thingspeak.com",80
AT+CIPSEND=0,53
GET /update?api_key=GVDN5WA12ZF3ZCU3&field1=27.44
AT+CIPCLOSE=0
AT+CWQAP
AT+RST
AT
AT+CWMODE=1
AT+CWJAP="test",""
AT+CWJAP="test",""
AT+CWJAP="test",""
AT+CWJAP="test",""
AT+CWJAP="test",""
AT+CWJAP="test",""
AT+CIPMUX=1
AT+CIPSTART=0,"TCP","api.thingspeak.com",80
AT+CIPSEND=0,53
GET /update?api_key=GVDN5WA12ZF3ZCU3&field1=27.19
AT+CIPCLOSE=0
Fig. 4 Log of communications between the slave and ESP8266.

PCD Design




The design rule check for this PCB can be viewed here.

PCB Test
Both the ATmega328p's needed to be flashed and programmed before soldering to the devixe.The following shows the PCB in operation.



The master microcontroler appers to have ishues comminicating with the temperature sensor. It is belived this is due to soldering errors.Otherwise the PCB performs as expected.

Discussion
The device works as requested, however there are some inprovements that can be made. This system does not use the ESP8266s ability to scan for access points or to host a HTML based configuration page which would make configureing Wi-Fi much more user friendly. The silkscreen was also rendered at a higher resolution than the previous PCB.

Links to Scripts
Temperature Master Script
Temperature Slave Script