Browse Source

12V power mod and voltage reading

lightsleep
Hendrik Langer 7 years ago
parent
commit
0323ba13ca
  1. 18
      README.md
  2. 11
      src/main.cpp

18
README.md

@ -12,6 +12,10 @@ Features:
* needs 5V power supply
* opensensemap.org API
Power consumption:
* ~50mA @ 5V
* (45mA idle + fan + wifi)
CAD files (OpenSCAD) and source code included.
@ -72,6 +76,20 @@ RadiationD-v1.1(CAJOE):
- 5V -> 5V
- VIN -> D6
12V power mod with step down converter and voltage divider for voltage measurement:
BAT+ --+--------------.
\R\ |
\1\ '
>---+--------------------------------- A0
/R/ | . ________________
/2/ === C1 +---| buck converter |---- 5V
BAT- --'------+-----------|________________|---- GND
Example values: R1=1MΩ, R2=100kΩ, C1=some ceramic capacitor (optional)
measures up to ~30V
## ToDo
* https://hackaday.com/2014/10/25/use-a-cheap-pin-diode-as-a-geiger-counter/ (opengeiger.de/elektronik.html)
* Solar power

11
src/main.cpp

@ -27,8 +27,6 @@ extern "C" {
#include <SDS011.h>
const char* server = "ingress.opensensemap.org";
//const char* ssid = "Freifunk";
//const char* password = "";
#define MQTT_MAX_PACKET_SIZE 512
const char* mqttserver = "home.xd0.de";
@ -38,6 +36,8 @@ const char* mqttpassword = "password4";
constexpr unsigned int postingInterval = 60000; //Uploadintervall in Millisekunden
constexpr unsigned int dhcp_interval = 60*60*1000;
#define EXTERNAL_POWER 1
//senseBox ID
#define SENSEBOX_ID "5a9e9e38f55bff001a494877"
@ -73,7 +73,9 @@ static constexpr uint8_t GEIGER_PIN = D6;
static constexpr float CONV_FACTOR = 0.008120;
static constexpr float OWN_BACKGROUND_CPS = 0; // documentation says 0.2 (make sure value doesn't get negative if subtracting!)
#ifndef EXTERNAL_POWER
ADC_MODE(ADC_VCC);
#endif
ESP8266WiFiMulti wifiMulti;
@ -147,7 +149,11 @@ void ICACHE_FLASH_ATTR sendValues() {
sd.pressure /= 100;
bmp.getTemperature(&(sd.temp2));
#ifndef EXTERNAL_POWER
sd.voltage = ESP.getVcc()/1024.0;
#else
sd.voltage = analogRead(A0)*0.04285078 -0.05942125; // by linear regression for my(!) voltage divider. else: sd.voltage = analogRead(A0)*3.3*(R1+R2)/(R2*1024)
#endif
int sds_error = sds.read(&(sd.p25), &(sd.p10));
if(!sds_error) {
@ -170,6 +176,7 @@ void ICACHE_FLASH_ATTR sendValues() {
if (!sds_error) Serial.printf("Particles 10 : %6.2fµg/m³ (SDS011)\n", sd.p10);
if (!sds_error) Serial.printf("Particles 2.5: %6.2fµg/m³ (SDS011)\n", sd.p25);
if (sd.cpm > 0) Serial.printf("Radiation : %6.2fµSv/h (J305)\n", sd.radioactivity);
Serial.printf("Voltage : %6.2fV (ESP8266)\n", sd.voltage);
DynamicJsonBuffer jsonBuffer;
JsonArray& array = jsonBuffer.createArray();

Loading…
Cancel
Save