Skip to content

StratusPrint/esp8266-iot-node

Repository files navigation

Esp8266 IoT Node

Usage

Update paths and baud rate in the make script to fit your system

make
@echo "make upload_all           to upload all"
@echo "make upload_http          to upload http files"
@echo "make upload_server        to upload server files"
@echo "make upload_init          to upload init file"
@echo "make list                 to list all files"
@echo "make format               format filesystem"
@echo "make flash                reflash newest firmware"
@echo "make tty                  check if chip is connected to "$(PORT)
@echo "make baud                 check baud rate of port "$(PORT)

#Connecting to Hub

  1. Connect to the node directly through wifi
  2. navigate your browser to 192.168.4.1
  3. Input the hubs ssid and password and connect

#API Documantation ##General JSON Response { "id": [chip id], "data": [value] } ##GPIO gpio is to write or read on digital pins of the ESP8266. For example:

/gpio/[int:pin #]/[int:state||string:type]

###Examples /gpio/1/o sets pin number 1 to a output /gpio/1/i sets pin number 1 to a input /gpio/1/p sets pin number 1 to a pwm [100] /gpio/1 reads value from pin number 1 in JSON format ##DHT

    /gpio/1/dht  reads dht sensor from pin number 1

####DHT JSON RESPONSE

{ "id": [chip id], "temp": [float:value], "humi": [float:value] }

##Event Triggering [POST] NOT YET IMPLEMENTED This will send data to an endpoint when triggered

  /gpio/[int:pin #]/trig

####Payload {
"endpoint": url endpoint to send request to,
"host":host ip/url,
"port": port number
}

####Trigger JSON RESPONSE

{ "id": [chip id], "data": [bool:true] }

##ADC ADC is to write or read on anolog pin of the ESP8266. For example:
/adc/[char:r||w] ###Examples /adc/r reads value from adc /adc/w writes value to adc

##Connect Connect is to connect the node to a network
/connect?ssid=[ssid]&nkey=[networkkey]

#Calling API in Python

from urllib2 import Request, urlopen
from json import dumps

def get_temp(node_ip, gpio):

    req = Request(node_ip+"/"+gpio+"/dht")
    response_body = urlopen(req).read()
    data = json.loads(response_body)
    id = data['id']
    temp = data['temp']
    humidity = data['humi']
    print("temp: "+temp+" hunidity: "+ humi)

    return data

About

No description, website, or topics provided.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published