Skip to content

HublessGenericIoT/ESP8266

Repository files navigation

ESP8266 Arduino

Source Code

The source code for this Arduino project is located in main_esp9266_cs490

  • AdvancedWebServer_esp8266_cs490.(cpp/h) are the files that make up the Access Point and server funcitonality
  • mqtt_esp8266_cs490.(cpp/h) are the files that make up the MQTT functionality
  • main_esp9266_cs490.ino is the Arduino file that pulls in the functions from the two previously named files.
  • mqtt_config.h contains default values for the MQTT server credentials

In the ESP8266 parent directory are two scripts (get.sh and post.sh) that are used to communicate with the ESP8266 device when connected to its access point.

Requirements

In order to compile and upload the code to the ESP8266 device you must have the following:

Arduino IDE Configurations

  • Board: NodeMCU 1.0 (ESP-12E Module)
  • CPU Frequency: 80 MHz
  • Flash Size: 4M (3M SPIFFS)
  • Upload Speed: 115200
  • Port
    • On Mac: /dev/cu.SLAB_USBtoUART
    • Linux: /tty/USB0
  • Programmer: AVRISP mkII

Library Tweaks

The PubSubClient library only allows a max packet size of 128 bytes by default. This causes an incoming message from AWS on a $aws/things/'device_id'/shadow/update/accepted when the device shadow changes to be ignored; the message size is >128. To solve this, update the variable 'MQTT_MAX_PACKET_SIZE', in the file 'PubSubClient.h', from 128 to 512.

  • Location:
    • Mac: /Users/'YourUsername'/Documents/Arduino/libraries/pubsubclient-2.6
    • Linux: /home/'YourUsername'/Arduino/libraries/PubSubClient/src