-
Notifications
You must be signed in to change notification settings - Fork 1
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Arduino sensor logging #4
Open
quinnc0
wants to merge
65
commits into
master
Choose a base branch
from
arduinoSensorLogging
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
65 commits
Select commit
Hold shift + click to select a range
a4be536
Added sensorlogger.ino
quinnc0 fbbc5ad
Update sensorlogger.ino
quinnc0 8f38c42
Update readme with sensorlogger.ino instructions
quinnc0 4bfd3a3
Make .csv default output type
quinnc0 3788985
Rename sensorlogger.ino to simplelogger.ino
quinnc0 078f578
Update README.md
quinnc0 9281fdc
Add sensorlogger.ino
quinnc0 be15cdd
Update readme for sensorlogger.ino
quinnc0 75eb44a
Clarify some commenting
quinnc0 322d667
Add support for voltmeter
quinnc0 817f208
Add BME280 support
quinnc0 5259155
Add ADS1015 support
quinnc0 202af30
Add adafruit anemometer support
quinnc0 b21f8e5
Add INA219 support
quinnc0 a1b58cc
update ads1115 and bme 280 support
quinnc0 983cbe6
Add support for multiple ds18b20s
quinnc0 97716fe
Add comments to help with configuration
quinnc0 4cfe03f
log column labels, i2c address choice added
quinnc0 8709f4c
Create ds18b20AddressFinder.ino
quinnc0 07aa120
Add DS18B20 addressing options
quinnc0 266907f
add detailed instructions for sensorlogger.ino
quinnc0 0b1b7d3
Add error msg, change INA reading
quinnc0 843fd6e
Add phototransistor specific support
quinnc0 d4eab7f
Update DS18B labels, activate all sensors
quinnc0 168e37d
added 3 second delay at start of program
quinnc0 f0d1899
Create README.md
quinnc0 a9123ce
Added fusion 360 source files
quinnc0 4dd2fc9
added shelter mock up design
quinnc0 b4aa9b5
add more 3d print source files
quinnc0 1a7f75c
Add screenshot of design
quinnc0 893cf8d
Update README.md
quinnc0 9931b17
Add files via upload
quinnc0 5c292c5
Rename sensorSerial.ino to sensorserial.ino
quinnc0 676f72d
Update readme for new files
quinnc0 229f809
Added logging of sensor data
quinnc0 a4e4f3f
remove vestigal code pertaining to SD
quinnc0 2ffb18c
add argument parser
quinnc0 849e1cc
prevents failed sensor from rebooting nodeMCU
quinnc0 984d709
added clarifying comment
quinnc0 6126763
Added retries to SD init and SD write
quinnc0 1e3751e
add error blink code info
quinnc0 9f9a770
rename a sensor and activate LED
quinnc0 f9e1d66
create readme
quinnc0 3d3147e
add source files
quinnc0 4e42035
Update README.md
quinnc0 317c902
Add files via upload
quinnc0 c113e07
Delete sensorlogger-nodemcu/ads1115anemometerwrap directory
quinnc0 8572023
Delete sensorlogger-nodemcu/ads1115phototransistorwrap directory
quinnc0 eb324e5
Delete sensorlogger-nodemcu/ina219wrap directory
quinnc0 f13cd88
Add files via upload
quinnc0 82fbe10
Update voltmeterwrap.h
quinnc0 67aa54d
Update sensorwrap.h
quinnc0 04be9db
move ifndef
quinnc0 ac38c4b
move ifndef
quinnc0 61bd192
move ifndef
quinnc0 dac59d3
disable sensor classes
quinnc0 4de8b4f
switch case bug fix
quinnc0 71fb178
clean up comments
quinnc0 c32ae37
Move sensorserial to its own folder
quinnc0 88370a2
add instructions for gopro_as_webcam_on_linux
quinnc0 fffd71a
Add Station M1 armbian setup instructions
quinnc0 90ab502
add all weather station logs
quinnc0 bf8869b
Add most recent logs
quinnc0 01be395
readme for logs
quinnc0 8247636
Update README.md
quinnc0 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,10 @@ | ||
# ecs | ||
Environmental control systems | ||
|
||
## sensorlogger.py | ||
--- | ||
|
||
# sensorlogger.py | ||
Used for logging temperature data to a raspberry pi's SD card. Requires DS18B20, DHT11, or DHT22 sensor. | ||
### Super basic instructions | ||
|
||
- Write raspberry pi OS to an SD card | ||
|
@@ -15,12 +18,10 @@ Requires python 3 | |
|
||
Requires 1-wire interface to be enabled in raspi-config for ds18b20 sensor https://www.raspberrypi-spy.co.uk/2018/02/enable-1-wire-interface-raspberry-pi/ | ||
|
||
To install dependencies: | ||
|
||
To install dependencies:</br> | ||
`pip install -r requirements.txt` | ||
|
||
Usage: | ||
|
||
Usage:</br> | ||
`python3 sensorlogger.py [GPIO pin #] [Sensor type] {-f output filename}` | ||
|
||
GPIO pin # and sensor type required. When -f is used, an output filename can be specified for the log file, defaults to [sensorname].log when -f is not used | ||
|
@@ -32,8 +33,159 @@ Sensor type is all lower case. dht11, dht22, or ds18b20 | |
## quickcsvplotter.py | ||
Plots the data collected by sensorlogger.py | ||
|
||
Usage: | ||
|
||
Usage:</br> | ||
`python3 quickcsvplotter.py [csv filename 1] [csv filename 2] ... [csv filename n]` | ||
|
||
Providing filenames in command line is optional. If no filenames are specified, all csvs in current directory will be plotted. | ||
|
||
--- | ||
|
||
# sensorlogger.ino | ||
Used to log data from a variety of sensors to an SD card, using a NodeMCU ESP8266 devkit. Other devices can be used, but some cannot fit the full program onto the flash memory. Also prints data to serial (115200 BAUD) , so can be monitored while running as well. A continuously flashing LED indicates an error with either the SD card or one of the sensors. | ||
|
||
### Supported sensors: | ||
- DS18B20 | ||
- BME280 | ||
- Phototransistor (like PT334-6C) | ||
- INA219 | ||
- Anemometer | ||
|
||
### Log file: | ||
The first line acts as column headers for the rest of the file. Each of the following lines consist of comma separated values for each of the measurements being taken. Each line is a seperate set of measurements. | ||
|
||
### Error blink code: | ||
- 2x blink: SD initialization error | ||
- ~10x blink: SD init ok, but SD write error | ||
|
||
## Flashing the NodeMCU ESP8266 | ||
To add support for NodeMCU board to Arduino IDE: | ||
|
||
1. Go to File -> Preferences -> "Additional Boards Manager URLs:", and paste https://arduino.esp8266.com/stable/package_esp8266com_index.json into the box. Click OK. | ||
2. Now click Tools -> Board: -> "Boards Manager...". In the seach bar, type "esp8266". Click on the esp8266 package, then click "Install". | ||
3. Restart Arduino IDE. Click Tools -> Board: -> ESP8266 Boards -> NodeMCU 1.0 (ESP-12E Module) | ||
|
||
To install required libraries: | ||
|
||
- Click Tools -> Manage Libraries..., then enter [library name] into search bar. Click "Install". If you are asked if you also want to install missing dependencies, click "Install All". | ||
|
||
Do the above step for the following libraries: | ||
- Dallas Temperature | ||
- Adafruit BME280 Library | ||
- Adafruit ADS1X15 | ||
- Adafruit INA219 | ||
|
||
Now you should be able to open the sensorlogger.ino sketch in the Arduino IDE and upload it to the NodeMCU ESP board. | ||
|
||
## sensorlogger.ino parameters | ||
Near the top of sensorlogger.ino, there is a list of parameters than can be changed according to your own hardware setup. | ||
|
||
**LOG_FILENAME** -> This is a string indicating the name of the log file. It must fit the 8.3 short format, so it can have a maximum of 8 characters, a period, and then 3 more characters. Each time the program is restarted, a new file is created, so if your LOG_FILENAME = "log.txt", log.txt will be created on the SD card. On subsequent runs, an underscore and a numeral will be appended to the filename. | ||
|
||
**POLL_INTERVAL** -> This is how long to wait between sensor readings, in milliseconds. | ||
|
||
**NO_SD** -> This is a boolean that allows the program to run without an SD card connected. Set to "true" to run program without SD card, "false" if you want to write data to SD. | ||
|
||
**SENSORS** -> This is an array that represents which sensors to take readings from. Each element is a struct of {(enum)[sensor type], (uint8_t)[pin number or hardware address]}. Valid sensor types are: ds18b20, voltmeter, bme280, ads1115, ads1115anemometer, and ina219. For the INA219, the second field will need to contain the hardware address. If you have not altered the INA219 module at all, the address is 0x40. For the BME280, the second field is irrelevant and any int works. For the devices connected through the ADS1115, the second field is the pin on that board. | ||
|
||
**DS18B20ADDRESSES** -> This is an array of the addresses of DS18B20 sensors being used and a corresponding label for each one. The addresses are device-specific, so will need to found by running ds18b20AddressFinder.ino with each of your sensors. The label will appear at the column header in the log file so we know which temperature readings come from which sensors. | ||
|
||
**CS_PIN** -> This is the chip select (CS) pin for the SPI interface af the SD card. | ||
|
||
**LED_PIN** -> This is the pin for the indicator LED. By default it is one of the built-in LEDs on the NodeMCU, but can be an external one if desired. | ||
|
||
# ds18b20AddressFinder.ino | ||
Use this to find addresses of all DS18B20 sensors being used. Make sure to mark each sensor as well so they don't get mixed up. It only requires the DallasTemperature library, which should have already been installed. | ||
|
||
## ds18b20AddressFinder.ino parameters | ||
|
||
**ONEWIRE_PIN** -> This is the pin that the data wire of the DS18B20 is connected to. | ||
|
||
## Getting your device addresses | ||
1. Connect first sensor to NodeMCU with ds18b20AddressFinder.ino. | ||
2. Connect NodeMCU to computer with Arduino IDE (or other serial monitor). | ||
3. Open serial monitor and make sure it's at 115200 BAUD. | ||
4. Every 5 seconds, the sensor's address will be printed. Copy that to sensorlogger.ino or just record it for later. | ||
5. Repeat for each DS18B20 you intend to use. Remember to indicate somehow which sensor corresponds to which address. | ||
|
||
--- | ||
|
||
# sensorserial.ino and get_data_from_mcu.py | ||
Used to send data from a variety of sensors to a PC via USB, using a NodeMCU ESP8266 devkit. A continuously flashing LED indicates an error with either the SD card or one of the sensors. This program is very similar to sensorlogger.ino, but it sends data to a PC running a python script rather than log to SD, and the python script controls the timiing of the sensor polls. | ||
|
||
## Setting up NodeMCU ESP8266 | ||
Follow the same steps as for sensorlogger.ino. Then plug the NodeMCU via USB into a computer that will run the python script. | ||
|
||
## get_data_from_mcu.py | ||
To be run from terminal on a PC, Raspberry Pi, etc:</br> | ||
`python3 get_data_from_mcu.py [poll_interval]` | ||
|
||
[poll_interval] is the time in seconds between sensor polls, and is an optional argument. Default poll interval is 3 seconds. | ||
|
||
Whenever restarting script, NodeMCU should be restarted as well. | ||
|
||
# Station M1 setup | ||
|
||
## Installing armbian on station m1 | ||
|
||
- Get the CLI version from here: | ||
https://www.armbian.com/station-m1/ | ||
|
||
- Write the image to an SD card with something like BalenaEtcher | ||
|
||
- Create password for root. | ||
- Create username and password. | ||
|
||
### Set up wifi: | ||
- Load the armbian-config utility:</br> | ||
`sudo armbian-config` | ||
|
||
- Choose Network->Wifi, then find your wifi network and enter the password. | ||
|
||
## Set up autologin: | ||
|
||
- Create autologin.conf file:</br> | ||
`sudo nano /etc/systemd/system/[email protected]/autologin.conf` | ||
|
||
- Fill it with this (change "wetfish" to whatever your username is): | ||
```ini | ||
[Service] | ||
ExecStart= | ||
ExecStart=-/sbin/agetty --autologin wetfish --noclear %I $TERM | ||
``` | ||
|
||
- then: | ||
`sudo systemctl daemon-reload` | ||
|
||
- then reboot to confirm it works | ||
|
||
## Install kernel headers | ||
|
||
- Get the kernel version: | ||
`uname -r` | ||
It should be "6.1.11-media" | ||
|
||
- Find all kernel headers packages: | ||
`sudo apt search linux-headers-` | ||
The one we want is linux-headers-current-media. the description says it's for 6.1.11-media. If your kernel is different, find the right one. | ||
|
||
- Then install the headers | ||
`sudo apt install linux-headers-current-media` | ||
|
||
## GoPro as webcam setup | ||
https://github.com/jschmid1/gopro_as_webcam_on_linux | ||
|
||
- Install gopro_as_webcam_on_linux:</br> | ||
`sudo su -c "bash <(wget -qO- https://cutt.ly/PjNkrzq)" root` | ||
|
||
- Install dependencies:</br> | ||
`sudo apt install ffmpeg v4l2loopback-dkms curl vlc` | ||
|
||
- Plug in gopro via usb and power it on (single press of power button on left). The screen should show a charging icon. | ||
This process needs to continue running, so open a new terminal and type:</br> | ||
`sudo gopro webcam -n -a` | ||
|
||
This starts gopro in webcam mode using auto settings (-a), and no input from user (-n). | ||
|
||
Once everything gets initialized, near the bottom of the output, look for a line like this:</br> | ||
`Output #0, video4linux,v4l2, to '/dev/video42'`</br> | ||
This means my gopro's device id is 42. remember this. |
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
|
||
<img width="623" alt="shelter assembly" src="https://user-images.githubusercontent.com/101291273/177421951-75a0e291-674e-4229-bc82-77fb8233faad.png"> | ||
|
||
## 3D Printed Parts | ||
All 3D printed parts should be printed in PETG or other plastic that can withstand some heating. |
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There's a typo here, you need to remove the space at the beginning of the line