Coder Social home page Coder Social logo

esp32's Introduction

ESP32 Microcontroller Sensor code

This contains the code to enable sensor readings utilising an ESP32 microcontroller

This is a work in progress

Diagram of project

Breadboard schematic

Breadboard schematic

Getting Started

Clone this repo to a location from which you can upload to your ESP32 microcontroller running MicroPython

git clone https://github.com/mqvivarium/EP32.git

Config

Copy config/config.py.example to config/config.py, then adjust the config values

# Set the SSID for your WiFi network
SSID = 'YourSSID'

# Set the password for your WiFi network
WIFI_PASSWORD = 'YourWIFIPassword'

# Time in seconds to wait between registering on the network
# and attempting the sensor readings
NETWORK_WAIT = 20

# IP address of your MQTT broker
MQTT_BROKER = '127.0.0.1'

# Client name you want to publish to your broker as
CLIENT_ID = 'ClientName'

# Name to give the temperature reading topic
TOPIC_TEMP = 'NameOfTemperatureTopic'

# Name to give the humidity reading topic
TOPIC_HUMID = 'NameOfHumidityTopic'

# Time in seconds between each attempt reading the DHT22, MUST be greater than 2
SENSOR_SLEEP = 30

# Data in pin number
DHT22_PIN = 15

# Publish data LED pin number (optional), set to None if no LED used
LED_PUBLISH_PIN = None

# Read data LED pin number (optional), set to None if no LED used
LED_READ_PIN = None

Copy files to your board

Copy main.py, config/ and mq/ to the root of your board

You should then have a structure like

/home/pi/projects/ESP32> ls -la /pyboard/
    75 Jan  1 2000  boot.py
     0 Jan  1 2000  config/
   249 Jan  1 2000  main.py
     0 Jan  1 2000  mq/

Dependencies

You will need a copy of the micropython-lib umqtt.simple file

simple.py

Make a directory umqtt in root of your board and copy simple.py to that directory.

/home/pi/projects/ESP32> mkdir /pyboard/umqtt
/home/pi/projects/ESP32> cp simple.py /pyboard/uqmtt/

Running the code

When the ESP32 microcontroller boots it will automatically run the main.py file. So just rebooting the board is sufficient to connect to your WiFi network and begin reading the sensor data.

Sensor data will be published to your MQTT broker at the interval your specified in the configuration file.

esp32's People

Contributors

mikeq avatar

Watchers

 avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.