Skip to content

Commit

Permalink
Merge pull request #6 from jkittley/serial-only
Browse files Browse the repository at this point in the history
Major updates.
  • Loading branch information
jkittley committed Mar 27, 2018
2 parents c40ffdc + 15477b1 commit 34b4663
Show file tree
Hide file tree
Showing 102 changed files with 63,629 additions and 2,752 deletions.
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -10,3 +10,6 @@ docs/Makefile
*.afdesign
server/test/.pytest_cache/
server/.pytest_cache/

device/arduino/BLE
device/arduino/RFM69
3 changes: 0 additions & 3 deletions device/arduino/RFM69/feather/readme.md

This file was deleted.

223 changes: 0 additions & 223 deletions device/arduino/RFM69/feather/test/test.ino

This file was deleted.

43 changes: 43 additions & 0 deletions device/arduino/serial_test/serial_test.ino
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
//
// This sketch is designed to test the serial port.
//
#include <ArduinoJson.h>

String device_id = "test_device_1";
// ========================
// Setup
// ========================

void setup() {
Serial.begin(11520);
while (!Serial) {
; // wait for serial port to connect.
}
}

// ========================
// Loop
// ========================
void loop() {

sendReading("float", "signal", "db", random(0,450)/10);
sendReading("int", "light_level", "lux", random(300,500)/10);
sendReading("bool", "switch", "state", random(0,2));

delay(3000);
}

void sendReading(String dtype, String field_name, String unit, int value) {
StaticJsonBuffer<200> jsonBuffer;
JsonObject& root = jsonBuffer.createObject();
root["device_id"] = device_id;
root["dtype"] = dtype;
root["field"] = field_name;
root["unit"] = unit;
root["value"] = value;
root["utc"] = "NOW";
root.printTo(Serial);
Serial.println();
delay(100);
}

16 changes: 16 additions & 0 deletions device/arduino/wifi_test/readme.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
# Little Sense - Arduino REST API Example
This example code demonstrates how easy it is to set up a new sensor which sends information to LittleSense via the Wifi network. The device interacts with the LittleSense RESTful API. Further information can be found in the main [LittleSense documentations](http://littlesense.readthedocs.io).

## Hardware
This example uses the low cost [Wemos](http://wemos.cc) modules. In particular the [Wemos mini Pro](https://wiki.wemos.cc/products:d1:d1_mini_pro]). However should work well with most Arduinos and ESP8266 WiFi sheilds. We chose Wemos because the WiFI is integrated and there are a number of sheilds such as the [battery shield](https://wiki.wemos.cc/products:d1_mini_shields:battery_shield) and the [Humidity & Temperature (DHT) sheild](https://wiki.wemos.cc/products:d1_mini_shields:dht_shield) which can be plugged in to one another to make sensors devices withou any wiring.

### Dependancies
1. Install the [CP210x USB to UART Bridge VCP Drivers](https://www.silabs.com/products/development-tools/software/usb-to-uart-bridge-vcp-drivers) so that we can connect and upload via a serial connection. Once installed the board should appear in the ports menu as `/dev/cu.SLAB_USBtoUART/` on Mac/Linux and something like `USB-SERIAL CH340` on Windows.

2. Add Wemos board support to the Arduino IDE. There's a detailed tutorial [on instructables](http://www.instructables.com/id/Programming-the-WeMos-Using-Arduino-SoftwareIDE/) which has lots of images. Here we will cover the basic steps.
1. Open the Arduino IDE preferences panel and add `http://arduino.esp8266.com/stable/package_esp8266com_index.json` to the "Additional Boards Manager URLs". If there is already something in this box then add a comma and the paste the URL to create a comma seporated list.
2. Open the Arduino boards manager and search for "esp8266". You should see a result for "esp8266 by ESP8266 Community". Install this package and restart the Arduino IDE.
3. Add the ArduinoJson library to the Arduino IDE. Open the libraries manager and search for "ArduinoJson". You should see a result titled: "ArduinoJson by Benolt Blanchon", install it.

## Software
The file `basic.ino` contains all the code you need. Open it up in the Arduino IDE, read the comments and change the settings as instructed. Make sure you select the correct port and board from the menu and upload. The script will periodically send test data to the server. Add some sensors and adapt the code to suite your needs.

0 comments on commit 34b4663

Please sign in to comment.