Commit 3
This commit is contained in:
		
							parent
							
								
									9e702af8c6
								
							
						
					
					
						commit
						2e2687d3f7
					
				| 
						 | 
					@ -3,6 +3,9 @@
 | 
				
			||||||
 | 
					
 | 
				
			||||||
#include <stdint.h>
 | 
					#include <stdint.h>
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					#define digitalPinToInterrupt(p)    p
 | 
				
			||||||
 | 
					
 | 
				
			||||||
static const uint8_t LED_BUILTIN = 8;
 | 
					static const uint8_t LED_BUILTIN = 8;
 | 
				
			||||||
#define BUILTIN_LED LED_BUILTIN  // backward compatibility
 | 
					#define BUILTIN_LED LED_BUILTIN  // backward compatibility
 | 
				
			||||||
#define LED_BUILTIN LED_BUILTIN  // allow testing #ifdef LED_BUILTIN
 | 
					#define LED_BUILTIN LED_BUILTIN  // allow testing #ifdef LED_BUILTIN
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -0,0 +1,22 @@
 | 
				
			||||||
 | 
					Gauche
 | 
				
			||||||
 | 
					------
 | 
				
			||||||
 | 
					blanc
 | 
				
			||||||
 | 
					orange
 | 
				
			||||||
 | 
					vert
 | 
				
			||||||
 | 
					-
 | 
				
			||||||
 | 
					-
 | 
				
			||||||
 | 
					gris
 | 
				
			||||||
 | 
					violet
 | 
				
			||||||
 | 
					bleu
 | 
				
			||||||
 | 
					jaune
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					Droite
 | 
				
			||||||
 | 
					------
 | 
				
			||||||
 | 
					-
 | 
				
			||||||
 | 
					brun
 | 
				
			||||||
 | 
					rouge
 | 
				
			||||||
 | 
					-
 | 
				
			||||||
 | 
					-
 | 
				
			||||||
 | 
					-
 | 
				
			||||||
 | 
					-
 | 
				
			||||||
 | 
					-
 | 
				
			||||||
| 
		 Before Width: | Height: | Size: 682 KiB After Width: | Height: | Size: 682 KiB  | 
							
								
								
									
										141
									
								
								platformio.ini
								
								
								
								
							
							
						
						
									
										141
									
								
								platformio.ini
								
								
								
								
							| 
						 | 
					@ -10,9 +10,11 @@
 | 
				
			||||||
 | 
					
 | 
				
			||||||
[platformio]
 | 
					[platformio]
 | 
				
			||||||
;default_envs = esp32_cc1101
 | 
					;default_envs = esp32_cc1101
 | 
				
			||||||
;default_envs = esp32c3_cdc_cc1101
 | 
					default_envs = esp32c3_cdc_cc1101
 | 
				
			||||||
default_envs = esp32s3_cdc_sx1278
 | 
					;default_envs = esp32s3_cdc_sx1278
 | 
				
			||||||
;default_envs = esp32c3_cdc_sx1278
 | 
					;default_envs = esp32c3_cdc_sx1278
 | 
				
			||||||
 | 
					;default_envs = rp2040_cdc_sx1278
 | 
				
			||||||
 | 
					;default_envs = esp32_sx1278
 | 
				
			||||||
boards_dir = boards
 | 
					boards_dir = boards
 | 
				
			||||||
 | 
					
 | 
				
			||||||
[libraries]
 | 
					[libraries]
 | 
				
			||||||
| 
						 | 
					@ -30,22 +32,23 @@ rtl_433_ESP = https://github.com/NorthernMan54/rtl_433_ESP
 | 
				
			||||||
framework = arduino
 | 
					framework = arduino
 | 
				
			||||||
monitor_filters = esp32_exception_decoder
 | 
					monitor_filters = esp32_exception_decoder
 | 
				
			||||||
;platform = espressif32@3.5.0
 | 
					;platform = espressif32@3.5.0
 | 
				
			||||||
;platform = espressif32@6.1.0
 | 
					platform = espressif32@6.1.0
 | 
				
			||||||
platform = espressif32
 | 
					;lib_ldf_mode = deep+
 | 
				
			||||||
lib_ldf_mode = deep+
 | 
					lib_ldf_mode = chain+
 | 
				
			||||||
lib_deps = 
 | 
					lib_deps = 
 | 
				
			||||||
  sui77/rc-switch
 | 
					  ; sui77/rc-switch
 | 
				
			||||||
 | 
					  ; https://github.com/1technophile/NewRemoteSwitch
 | 
				
			||||||
  ${libraries.arduinolog}
 | 
					  ${libraries.arduinolog}
 | 
				
			||||||
  ${libraries.arduinojson}
 | 
					  ${libraries.arduinojson}
 | 
				
			||||||
  ${libraries.rtl_433_ESP}
 | 
					  ${libraries.rtl_433_ESP}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
[env:esp32s3_cdc_sx1278]
 | 
					[env:esp32_sx1278]
 | 
				
			||||||
board = seeed_xiao_esp32s3
 | 
					board = wemos_d1_mini32
 | 
				
			||||||
build_flags =
 | 
					build_flags =
 | 
				
			||||||
  '-DCONFIG_ESP_CONSOLE_UART=1' ; settings for esp32c3 without uart
 | 
					  ;'-DCONFIG_ESP_CONSOLE_UART=1' ; settings for esp32c3 without uart
 | 
				
			||||||
  '-DARDUINO_USB_MODE=1'
 | 
					  ;'-DARDUINO_USB_MODE=1'
 | 
				
			||||||
  '-DARDUINO_USB_CDC_ON_BOOT=1'
 | 
					  ;'-DARDUINO_USB_CDC_ON_BOOT=1'
 | 
				
			||||||
  '-DLOG_LEVEL=LOG_LEVEL_TRACE'
 | 
					  ;'-DLOG_LEVEL=LOG_LEVEL_TRACE'
 | 
				
			||||||
  ;'-DOOK_FIXED_THRESHOLD=0x6E'
 | 
					  ;'-DOOK_FIXED_THRESHOLD=0x6E'
 | 
				
			||||||
  ;'-DAUTOOOKFIX=1'
 | 
					  ;'-DAUTOOOKFIX=1'
 | 
				
			||||||
  ;'-DPUBLISH_UNPARSED=true'
 | 
					  ;'-DPUBLISH_UNPARSED=true'
 | 
				
			||||||
| 
						 | 
					@ -53,15 +56,49 @@ build_flags =
 | 
				
			||||||
  ;'-DDEMOD_DEBUG=true'
 | 
					  ;'-DDEMOD_DEBUG=true'
 | 
				
			||||||
  '-DOOK_MODULATION=true'      ; False is FSK, True is OOK
 | 
					  '-DOOK_MODULATION=true'      ; False is FSK, True is OOK
 | 
				
			||||||
  '-DRF_SX1278="SX1278"'  ; CC1101 Transceiver Module
 | 
					  '-DRF_SX1278="SX1278"'  ; CC1101 Transceiver Module
 | 
				
			||||||
  '-DRF_MODULE_DIO0=8'   ; CC1101 pin GDO0
 | 
					  '-DRF_MODULE_DIO0=21'   ; CC1101 pin GDO0
 | 
				
			||||||
  '-DRF_MODULE_DIO1=44'    ; CC1101 pin GDO2
 | 
					  '-DRF_MODULE_DIO1=22'    ; CC1101 pin GDO2
 | 
				
			||||||
  '-DRF_MODULE_DIO2=7'
 | 
					  '-DRF_MODULE_DIO2=16'
 | 
				
			||||||
  '-DRF_MODULE_RST=43'    ; CC1101 pin GDO2
 | 
					  '-DRF_MODULE_RST=26'    ; CC1101 pin GDO2
 | 
				
			||||||
  ;'-DRF_MODULE_SCK=9'         ; SPI Clock
 | 
					  '-DRF_MODULE_CS=5'          ; SPI Chip select
 | 
				
			||||||
  ;'-DRF_MODULE_MISO=1'        ; SPI Serial Output
 | 
					 | 
				
			||||||
  ;'-DRF_MODULE_MOSI=2'        ; SPI Serial Input
 | 
					 | 
				
			||||||
  '-DRF_MODULE_CS=3'          ; SPI Chip select
 | 
					 | 
				
			||||||
  '-DRF_MODULE_INIT_STATUS=true'    ; Display transceiver config during startup
 | 
					  '-DRF_MODULE_INIT_STATUS=true'    ; Display transceiver config during startup
 | 
				
			||||||
 | 
					  '-DRADIOLIB_DEBUG=true'
 | 
				
			||||||
 | 
					targets = upload
 | 
				
			||||||
 | 
					monitor_port = /dev/ttyUSB0
 | 
				
			||||||
 | 
					monitor_speed = 115200
 | 
				
			||||||
 | 
					upload_port = /dev/ttyUSB0
 | 
				
			||||||
 | 
					monitor_filters =
 | 
				
			||||||
 | 
					  default   ; Remove typical terminal control codes from input
 | 
				
			||||||
 | 
					  time      ; Add timestamp with milliseconds for each new line
 | 
				
			||||||
 | 
					;  log2file  ; Log data to a file “platformio-device-monitor-*.log” located in the current working directory
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					[env:esp32s3_cdc_sx1278]
 | 
				
			||||||
 | 
					board = waveshare_esp32_s3_zero
 | 
				
			||||||
 | 
					build_flags =
 | 
				
			||||||
 | 
					  ;'-DMY_DEVICES=true'
 | 
				
			||||||
 | 
					  ;'-DDISABLERSSITHRESHOLD=true'
 | 
				
			||||||
 | 
					  '-DCONFIG_ESP_CONSOLE_UART=1' ; settings for esp32c3 without uart
 | 
				
			||||||
 | 
					  ;'-DARDUINO_USB_MODE=1'
 | 
				
			||||||
 | 
					  ;'-DARDUINO_USB_CDC_ON_BOOT=1'
 | 
				
			||||||
 | 
					  '-DLOG_LEVEL=LOG_LEVEL_TRACE'
 | 
				
			||||||
 | 
					  ;'-DOOK_FIXED_THRESHOLD=0x6E'
 | 
				
			||||||
 | 
					  ;'-DAUTOOOKFIX=1'
 | 
				
			||||||
 | 
					  '-DPUBLISH_UNPARSED=true'
 | 
				
			||||||
 | 
					  '-DRAW_SIGNAL_DEBUG=true'   ; display raw received messages
 | 
				
			||||||
 | 
					  '-DSIGNAL_RSSI=true'
 | 
				
			||||||
 | 
					  '-DDEMOD_DEBUG=true'
 | 
				
			||||||
 | 
					  '-DOOK_MODULATION=true'      ; False is FSK, True is OOK
 | 
				
			||||||
 | 
					  '-DRF_SX1278="SX1278"'  ; CC1101 Transceiver Module
 | 
				
			||||||
 | 
					  '-DRF_MODULE_DIO0=11'   ; CC1101 pin GDO0
 | 
				
			||||||
 | 
					  '-DRF_MODULE_DIO1=9'    ; CC1101 pin GDO2
 | 
				
			||||||
 | 
					  '-DRF_MODULE_DIO2=8'
 | 
				
			||||||
 | 
					  '-DRF_MODULE_RST=4'    ; CC1101 pin GDO2
 | 
				
			||||||
 | 
					  ;'-DRF_MODULE_SCK=12'         ; SPI Clock
 | 
				
			||||||
 | 
					  ;'-DRF_MODULE_MISO=13'        ; SPI Serial Output
 | 
				
			||||||
 | 
					  ;'-DRF_MODULE_MOSI=5'        ; SPI Serial Input
 | 
				
			||||||
 | 
					  '-DRF_MODULE_CS=10'          ; SPI Chip select
 | 
				
			||||||
 | 
					  '-DRF_MODULE_INIT_STATUS=true'    ; Display transceiver config during startup
 | 
				
			||||||
 | 
					  ;'-DRADIOLIB_DEBUG=true'
 | 
				
			||||||
targets = upload
 | 
					targets = upload
 | 
				
			||||||
monitor_port = /dev/ttyACM0
 | 
					monitor_port = /dev/ttyACM0
 | 
				
			||||||
monitor_speed = 115200
 | 
					monitor_speed = 115200
 | 
				
			||||||
| 
						 | 
					@ -78,6 +115,8 @@ build_flags =
 | 
				
			||||||
  '-DARDUINO_USB_MODE=1'
 | 
					  '-DARDUINO_USB_MODE=1'
 | 
				
			||||||
  '-DARDUINO_USB_CDC_ON_BOOT=1'
 | 
					  '-DARDUINO_USB_CDC_ON_BOOT=1'
 | 
				
			||||||
  '-DLOG_LEVEL=LOG_LEVEL_TRACE'
 | 
					  '-DLOG_LEVEL=LOG_LEVEL_TRACE'
 | 
				
			||||||
 | 
					  '-DMY_DEVICES=true'
 | 
				
			||||||
 | 
					  '-DDISABLERSSITHRESHOLD=true'
 | 
				
			||||||
  ;'-DOOK_FIXED_THRESHOLD=0x6E'
 | 
					  ;'-DOOK_FIXED_THRESHOLD=0x6E'
 | 
				
			||||||
  ;'-DAUTOOOKFIX=1'
 | 
					  ;'-DAUTOOOKFIX=1'
 | 
				
			||||||
  ;'-DPUBLISH_UNPARSED=true'
 | 
					  ;'-DPUBLISH_UNPARSED=true'
 | 
				
			||||||
| 
						 | 
					@ -85,14 +124,50 @@ build_flags =
 | 
				
			||||||
  ;'-DDEMOD_DEBUG=true'
 | 
					  ;'-DDEMOD_DEBUG=true'
 | 
				
			||||||
  '-DOOK_MODULATION=true'      ; False is FSK, True is OOK
 | 
					  '-DOOK_MODULATION=true'      ; False is FSK, True is OOK
 | 
				
			||||||
  '-DRF_SX1278="SX1278"'  ; CC1101 Transceiver Module
 | 
					  '-DRF_SX1278="SX1278"'  ; CC1101 Transceiver Module
 | 
				
			||||||
  '-DRF_MODULE_DIO0=8'   ; CC1101 pin GDO0
 | 
					  '-DRF_MODULE_DIO0=1'   ; CC1101 pin GDO0
 | 
				
			||||||
  '-DRF_MODULE_DIO1=44'    ; CC1101 pin GDO2
 | 
					  '-DRF_MODULE_DIO1=3'    ; CC1101 pin GDO2
 | 
				
			||||||
  '-DRF_MODULE_DIO2=7'
 | 
					  '-DRF_MODULE_DIO2=0'
 | 
				
			||||||
  '-DRF_MODULE_RST=44'    ; CC1101 pin GDO2
 | 
					  '-DRF_MODULE_RST=20'    ; CC1101 pin GDO2
 | 
				
			||||||
  ;'-DRF_MODULE_SCK=9'         ; SPI Clock
 | 
					  ;'-DRF_MODULE_SCK=9'         ; SPI Clock
 | 
				
			||||||
  ;'-DRF_MODULE_MISO=1'        ; SPI Serial Output
 | 
					  ;'-DRF_MODULE_MISO=1'        ; SPI Serial Output
 | 
				
			||||||
  ;'-DRF_MODULE_MOSI=2'        ; SPI Serial Input
 | 
					  ;'-DRF_MODULE_MOSI=2'        ; SPI Serial Input
 | 
				
			||||||
  '-DRF_MODULE_CS=3'          ; SPI Chip select
 | 
					  '-DRF_MODULE_CS=7'          ; SPI Chip select
 | 
				
			||||||
 | 
					  '-DRF_MODULE_INIT_STATUS=true'    ; Display transceiver config during startup
 | 
				
			||||||
 | 
					targets = upload
 | 
				
			||||||
 | 
					monitor_port = /dev/ttyACM0
 | 
				
			||||||
 | 
					monitor_speed = 115200
 | 
				
			||||||
 | 
					upload_port = /dev/ttyACM0
 | 
				
			||||||
 | 
					monitor_filters =
 | 
				
			||||||
 | 
					  default   ; Remove typical terminal control codes from input
 | 
				
			||||||
 | 
					  time      ; Add timestamp with milliseconds for each new line
 | 
				
			||||||
 | 
					;  log2file  ; Log data to a file “platformio-device-monitor-*.log” located in the current working directory
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					[env:rp2040_cdc_sx1278]
 | 
				
			||||||
 | 
					platform = https://github.com/maxgerhardt/platform-raspberrypi.git
 | 
				
			||||||
 | 
					board = waveshare_rp2040_zero
 | 
				
			||||||
 | 
					board_build.core = earlephilhower
 | 
				
			||||||
 | 
					build_flags =
 | 
				
			||||||
 | 
					  '-DCONFIG_ESP_CONSOLE_UART=1' ; settings for esp32c3 without uart
 | 
				
			||||||
 | 
					  '-DARDUINO_USB_MODE=1'
 | 
				
			||||||
 | 
					  '-DARDUINO_USB_CDC_ON_BOOT=1'
 | 
				
			||||||
 | 
					  '-DLOG_LEVEL=LOG_LEVEL_TRACE'
 | 
				
			||||||
 | 
					  '-DMY_DEVICES=true'
 | 
				
			||||||
 | 
					  '-DDISABLERSSITHRESHOLD=true'
 | 
				
			||||||
 | 
					  ;'-DOOK_FIXED_THRESHOLD=0x6E'
 | 
				
			||||||
 | 
					  ;'-DAUTOOOKFIX=1'
 | 
				
			||||||
 | 
					  ;'-DPUBLISH_UNPARSED=true'
 | 
				
			||||||
 | 
					  ;'-DSIGNAL_RSSI=true'
 | 
				
			||||||
 | 
					  ;'-DDEMOD_DEBUG=true'
 | 
				
			||||||
 | 
					  '-DOOK_MODULATION=true'      ; False is FSK, True is OOK
 | 
				
			||||||
 | 
					  '-DRF_SX1278="SX1278"'  ; CC1101 Transceiver Module
 | 
				
			||||||
 | 
					  '-DRF_MODULE_DIO0=1'   ; CC1101 pin GDO0
 | 
				
			||||||
 | 
					  '-DRF_MODULE_DIO1=3'    ; CC1101 pin GDO2
 | 
				
			||||||
 | 
					  '-DRF_MODULE_DIO2=0'
 | 
				
			||||||
 | 
					  '-DRF_MODULE_RST=20'    ; CC1101 pin GDO2
 | 
				
			||||||
 | 
					  ;'-DRF_MODULE_SCK=9'         ; SPI Clock
 | 
				
			||||||
 | 
					  ;'-DRF_MODULE_MISO=1'        ; SPI Serial Output
 | 
				
			||||||
 | 
					  ;'-DRF_MODULE_MOSI=2'        ; SPI Serial Input
 | 
				
			||||||
 | 
					  '-DRF_MODULE_CS=7'          ; SPI Chip select
 | 
				
			||||||
  '-DRF_MODULE_INIT_STATUS=true'    ; Display transceiver config during startup
 | 
					  '-DRF_MODULE_INIT_STATUS=true'    ; Display transceiver config during startup
 | 
				
			||||||
targets = upload
 | 
					targets = upload
 | 
				
			||||||
monitor_port = /dev/ttyACM0
 | 
					monitor_port = /dev/ttyACM0
 | 
				
			||||||
| 
						 | 
					@ -110,6 +185,8 @@ build_flags =
 | 
				
			||||||
  '-DARDUINO_USB_MODE=1'
 | 
					  '-DARDUINO_USB_MODE=1'
 | 
				
			||||||
  '-DARDUINO_USB_CDC_ON_BOOT=1'
 | 
					  '-DARDUINO_USB_CDC_ON_BOOT=1'
 | 
				
			||||||
  '-DLOG_LEVEL=LOG_LEVEL_TRACE'
 | 
					  '-DLOG_LEVEL=LOG_LEVEL_TRACE'
 | 
				
			||||||
 | 
					  '-DMY_DEVICES=true'		; subset of devices
 | 
				
			||||||
 | 
					  '-DDISABLERSSITHRESHOLD=true'
 | 
				
			||||||
;  '-DONBOARD_LED=13'           ; LED_D4
 | 
					;  '-DONBOARD_LED=13'           ; LED_D4
 | 
				
			||||||
; *** rtl_433_ESP Options ***
 | 
					; *** rtl_433_ESP Options ***
 | 
				
			||||||
;  '-DRF_MODULE_FREQUENCY=915.00'
 | 
					;  '-DRF_MODULE_FREQUENCY=915.00'
 | 
				
			||||||
| 
						 | 
					@ -119,10 +196,9 @@ build_flags =
 | 
				
			||||||
;  '-DRAW_SIGNAL_DEBUG=true'   ; display raw received messages
 | 
					;  '-DRAW_SIGNAL_DEBUG=true'   ; display raw received messages
 | 
				
			||||||
;  '-DMEMORY_DEBUG=true'   ; display memory usage information
 | 
					;  '-DMEMORY_DEBUG=true'   ; display memory usage information
 | 
				
			||||||
;  '-DDEMOD_DEBUG=true'  ; display signal debug info
 | 
					;  '-DDEMOD_DEBUG=true'  ; display signal debug info
 | 
				
			||||||
;	'-DMY_DEVICES=true'		; subset of devices
 | 
					 | 
				
			||||||
;  '-DPUBLISH_UNPARSED=true'   ; publish unparsed signal details
 | 
					;  '-DPUBLISH_UNPARSED=true'   ; publish unparsed signal details
 | 
				
			||||||
  '-DDISABLERSSITHRESHOLD=true'
 | 
					;  '-DDISABLERSSITHRESHOLD=true'
 | 
				
			||||||
  '-DMINRSSI=-82'
 | 
					;  '-DMINRSSI=-82'
 | 
				
			||||||
;  '-DMINRSSI=-60'
 | 
					;  '-DMINRSSI=-60'
 | 
				
			||||||
;  '-DRSSI_THRESHOLD=12'         ; Apply a delta of 12 to average RSSI level
 | 
					;  '-DRSSI_THRESHOLD=12'         ; Apply a delta of 12 to average RSSI level
 | 
				
			||||||
;  '-DAVERAGE_RSSI=5000'     ; Display RSSI floor ( Average of 5000 samples )
 | 
					;  '-DAVERAGE_RSSI=5000'     ; Display RSSI floor ( Average of 5000 samples )
 | 
				
			||||||
| 
						 | 
					@ -130,9 +206,12 @@ build_flags =
 | 
				
			||||||
;  '-DOOK_MODULATION=false'       ; False is FSK, True is OOK
 | 
					;  '-DOOK_MODULATION=false'       ; False is FSK, True is OOK
 | 
				
			||||||
; *** RF Module Options ***
 | 
					; *** RF Module Options ***
 | 
				
			||||||
  '-DRF_CC1101="CC1101"'  ; CC1101 Transceiver Module
 | 
					  '-DRF_CC1101="CC1101"'  ; CC1101 Transceiver Module
 | 
				
			||||||
  '-DRF_MODULE_CS=21'      ; pin to be used as chip select
 | 
					  ;'-DRF_MODULE_CS=21'      ; pin to be used as chip select
 | 
				
			||||||
  '-DRF_MODULE_GDO0=6'   ; CC1101 pin GDO0
 | 
					  ;'-DRF_MODULE_GDO0=6'   ; CC1101 pin GDO0
 | 
				
			||||||
  '-DRF_MODULE_GDO2=5'    ; CC1101 pin GDO2
 | 
					  ;'-DRF_MODULE_GDO2=5'    ; CC1101 pin GDO2
 | 
				
			||||||
 | 
					  '-DRF_MODULE_CS=7'      ; pin to be used as chip select
 | 
				
			||||||
 | 
					  '-DRF_MODULE_GDO0=0'   ; CC1101 pin GDO0
 | 
				
			||||||
 | 
					  '-DRF_MODULE_GDO2=1'    ; CC1101 pin GDO2
 | 
				
			||||||
  '-DRF_MODULE_INIT_STATUS=true'    ; Display transceiver config during startup
 | 
					  '-DRF_MODULE_INIT_STATUS=true'    ; Display transceiver config during startup
 | 
				
			||||||
; *** RadioLib Options ***
 | 
					; *** RadioLib Options ***
 | 
				
			||||||
;  '-DRADIOLIB_DEBUG=true'
 | 
					;  '-DRADIOLIB_DEBUG=true'
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -1,9 +1,11 @@
 | 
				
			||||||
import json
 | 
					import json
 | 
				
			||||||
#import fileinput
 | 
					#import fileinput
 | 
				
			||||||
import serial
 | 
					import serial
 | 
				
			||||||
 | 
					import datetime
 | 
				
			||||||
 | 
					
 | 
				
			||||||
import paho.mqtt.client as paho
 | 
					import paho.mqtt.client as paho
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
#input = '{"model":"Oregon-THGR810","id":226,"channel":10,"battery_ok":0,"temperature_C":19.7,"humidity":24,"protocol":"Oregon Scientific Weather Sensor"}'
 | 
					#input = '{"model":"Oregon-THGR810","id":226,"channel":10,"battery_ok":0,"temperature_C":19.7,"humidity":24,"protocol":"Oregon Scientific Weather Sensor"}'
 | 
				
			||||||
SKIP_KEYS = [ "type", "model", "subtype", "channel", "id", "mic", "mod", "freq", "sequence_num", "message_type", "exception", "raw_msg", "protocol", "duration", "sync", "flags", "status" ]
 | 
					SKIP_KEYS = [ "type", "model", "subtype", "channel", "id", "mic", "mod", "freq", "sequence_num", "message_type", "exception", "raw_msg", "protocol", "duration", "sync", "flags", "status" ]
 | 
				
			||||||
TOPIC_KEYS = [ "type", "model", "subtype", "channel", "id" ]
 | 
					TOPIC_KEYS = [ "type", "model", "subtype", "channel", "id" ]
 | 
				
			||||||
| 
						 | 
					@ -11,10 +13,16 @@ TOPIC_KEYS = [ "type", "model", "subtype", "channel", "id" ]
 | 
				
			||||||
#default="devices[/type][/model][/subtype][/channel][/id]"
 | 
					#default="devices[/type][/model][/subtype][/channel][/id]"
 | 
				
			||||||
prefix = "home/rtl_433"
 | 
					prefix = "home/rtl_433"
 | 
				
			||||||
 | 
					
 | 
				
			||||||
broker = "192.168.67.1"
 | 
					broker = "127.0.0.1"
 | 
				
			||||||
port = 1883
 | 
					port = 1883
 | 
				
			||||||
 | 
					
 | 
				
			||||||
altitude = 150
 | 
					#altitude = 150
 | 
				
			||||||
 | 
					altitude = 210
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					rainref = -1
 | 
				
			||||||
 | 
					rainlast = -1
 | 
				
			||||||
 | 
					rainrefday = -1
 | 
				
			||||||
 | 
					rainday = -1
 | 
				
			||||||
 | 
					
 | 
				
			||||||
serialdev = "/dev/ttyACM0"
 | 
					serialdev = "/dev/ttyACM0"
 | 
				
			||||||
serialspeed = 115200
 | 
					serialspeed = 115200
 | 
				
			||||||
| 
						 | 
					@ -43,11 +51,15 @@ def publish(jsonin, prefix_device):
 | 
				
			||||||
def on_connect(client, userdata, flags, reason_code, properties):
 | 
					def on_connect(client, userdata, flags, reason_code, properties):
 | 
				
			||||||
  print(f"Connected to MQTT")
 | 
					  print(f"Connected to MQTT")
 | 
				
			||||||
  client.subscribe(prefix+"/cmd")
 | 
					  client.subscribe(prefix+"/cmd")
 | 
				
			||||||
 | 
					  client.subscribe(prefix+"/rain_reset")
 | 
				
			||||||
 | 
					
 | 
				
			||||||
def on_message(client, userdata, msg):
 | 
					def on_message(client, userdata, msg):
 | 
				
			||||||
 | 
					  global rainref
 | 
				
			||||||
  print(msg.topic+" "+str(msg.payload))
 | 
					  print(msg.topic+" "+str(msg.payload))
 | 
				
			||||||
  if(str(msg.topic) == prefix+"/cmd"):
 | 
					  if(str(msg.topic) == prefix+"/cmd"):
 | 
				
			||||||
    ser.write(msg.payload)
 | 
					    ser.write(msg.payload)
 | 
				
			||||||
 | 
					  if(str(msg.topic) == prefix+"/rain_reset"):
 | 
				
			||||||
 | 
					    rainref = rainlast
 | 
				
			||||||
 | 
					
 | 
				
			||||||
mqtt=paho.Client(paho.CallbackAPIVersion.VERSION2)
 | 
					mqtt=paho.Client(paho.CallbackAPIVersion.VERSION2)
 | 
				
			||||||
mqtt.on_connect = on_connect
 | 
					mqtt.on_connect = on_connect
 | 
				
			||||||
| 
						 | 
					@ -73,6 +85,23 @@ while True:
 | 
				
			||||||
  if 'pressure' in data:
 | 
					  if 'pressure' in data:
 | 
				
			||||||
    data['pressure'] = get_sealevel_pressure(data['pressure'], altitude, data['temperature_C'])
 | 
					    data['pressure'] = get_sealevel_pressure(data['pressure'], altitude, data['temperature_C'])
 | 
				
			||||||
    data['pressure'] = round(data['pressure'], 1)
 | 
					    data['pressure'] = round(data['pressure'], 1)
 | 
				
			||||||
 | 
					  if 'rain_mm' in data:
 | 
				
			||||||
 | 
					    if rainref == -1 or data['rain_mm'] < rainlast:
 | 
				
			||||||
 | 
					      rainref = data['rain_mm']
 | 
				
			||||||
 | 
					      rainrefday = data['rain_mm']
 | 
				
			||||||
 | 
					      rainlast = rainref
 | 
				
			||||||
 | 
					      rainday = datetime.datetime.now().day
 | 
				
			||||||
 | 
					      data['rain_local'] = 0
 | 
				
			||||||
 | 
					      data['rain_day'] = 0
 | 
				
			||||||
 | 
					    else:
 | 
				
			||||||
 | 
					      rainlast = data['rain_mm']
 | 
				
			||||||
 | 
					      data['rain_local'] = round(rainlast - rainref, 2)
 | 
				
			||||||
 | 
					      if datetime.datetime.now().day != rainday:
 | 
				
			||||||
 | 
					        rainday = datetime.datetime.now().day
 | 
				
			||||||
 | 
					        rainrefday = data['rain_mm']
 | 
				
			||||||
 | 
					        data['rain_day'] = 0
 | 
				
			||||||
 | 
					      else:
 | 
				
			||||||
 | 
					        data['rain_day'] = round(data['rain_mm'] - rainrefday,2)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
  mqtt.publish(prefix+'/events', json.dumps(data)) 
 | 
					  mqtt.publish(prefix+'/events', json.dumps(data)) 
 | 
				
			||||||
  prefix_device = generate_topic(data)
 | 
					  prefix_device = generate_topic(data)
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -71,34 +71,46 @@ def on_message(mqttc, obj, msg):
 | 
				
			||||||
                tags[t] = str(jsonin[t])
 | 
					                tags[t] = str(jsonin[t])
 | 
				
			||||||
        
 | 
					        
 | 
				
			||||||
        measures = ""
 | 
					        measures = ""
 | 
				
			||||||
 | 
					        measuresnb = 0
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        if 'temperature_C' in jsonin:
 | 
					        if 'temperature_C' in jsonin:
 | 
				
			||||||
            value = float(jsonin['temperature_C'])
 | 
					            value = float(jsonin['temperature_C'])
 | 
				
			||||||
 | 
					            measures += create_measure("temperature", currentts, tags, value)
 | 
				
			||||||
            if 'temperature' not in recorddb[ref] or recorddb[ref]['temperature'] != value:
 | 
					            if 'temperature' not in recorddb[ref] or recorddb[ref]['temperature'] != value:
 | 
				
			||||||
                measures += create_measure("temperature", currentts, tags, value)
 | 
					                measuresnb += 1
 | 
				
			||||||
                recorddb[ref]['temperature'] = value
 | 
					                recorddb[ref]['temperature'] = value
 | 
				
			||||||
        if 'humidity' in jsonin:
 | 
					        if 'humidity' in jsonin:
 | 
				
			||||||
            value = int(jsonin['humidity'])
 | 
					            value = int(jsonin['humidity'])
 | 
				
			||||||
 | 
					            measures += create_measure("humidity", currentts, tags, value)
 | 
				
			||||||
            if 'humidity' not in recorddb[ref] or recorddb[ref]['humidity'] != value:
 | 
					            if 'humidity' not in recorddb[ref] or recorddb[ref]['humidity'] != value:
 | 
				
			||||||
                measures += create_measure("humidity", currentts, tags, value)
 | 
					                measuresnb += 1
 | 
				
			||||||
                recorddb[ref]['humidity'] = value
 | 
					                recorddb[ref]['humidity'] = value
 | 
				
			||||||
        if 'moisture' in jsonin:
 | 
					        if 'moisture' in jsonin:
 | 
				
			||||||
            value = int(jsonin['moisture'])
 | 
					            value = int(jsonin['moisture'])
 | 
				
			||||||
 | 
					            measures += create_measure("moisture", currentts, tags, value)
 | 
				
			||||||
            if 'moisture' not in recorddb[ref] or recorddb[ref]['moisture'] != value:
 | 
					            if 'moisture' not in recorddb[ref] or recorddb[ref]['moisture'] != value:
 | 
				
			||||||
                measures += create_measure("moisture", currentts, tags, value)
 | 
					                measuresnb += 1
 | 
				
			||||||
                recorddb[ref]['moisture'] = value
 | 
					                recorddb[ref]['moisture'] = value
 | 
				
			||||||
 | 
					        if 'rain_mm' in jsonin:
 | 
				
			||||||
 | 
					            value = float(jsonin['rain_mm'])
 | 
				
			||||||
 | 
					            measures += create_measure("rain", currentts, tags, value)
 | 
				
			||||||
 | 
					            if 'rain' not in recorddb[ref] or recorddb[ref]['rain'] != value:
 | 
				
			||||||
 | 
					                measuresnb += 1
 | 
				
			||||||
 | 
					                recorddb[ref]['rain'] = value
 | 
				
			||||||
        if 'pressure' in jsonin:
 | 
					        if 'pressure' in jsonin:
 | 
				
			||||||
            value = float(jsonin['pressure'])
 | 
					            value = float(jsonin['pressure'])
 | 
				
			||||||
 | 
					            measures += create_measure("pressure", currentts, tags, value)
 | 
				
			||||||
            if 'pressure' not in recorddb[ref] or recorddb[ref]['pressure'] != value:
 | 
					            if 'pressure' not in recorddb[ref] or recorddb[ref]['pressure'] != value:
 | 
				
			||||||
                measures += create_measure("pressure", currentts, tags, value)
 | 
					                measuresnb += 1
 | 
				
			||||||
                recorddb[ref]['humidity'] = value
 | 
					                recorddb[ref]['pressure'] = value
 | 
				
			||||||
        if 'battery_ok' in jsonin:
 | 
					        if 'battery_ok' in jsonin:
 | 
				
			||||||
            value = int(jsonin['battery_ok'])
 | 
					            value = int(jsonin['battery_ok'])
 | 
				
			||||||
 | 
					            measures += create_measure("battery_ok", currentts, tags, value)
 | 
				
			||||||
            if 'battery_ok' not in recorddb[ref] or recorddb[ref]['battery_ok'] != value:
 | 
					            if 'battery_ok' not in recorddb[ref] or recorddb[ref]['battery_ok'] != value:
 | 
				
			||||||
                measures += create_measure("battery_ok", currentts, tags, value)
 | 
					                measuresnb += 1
 | 
				
			||||||
                recorddb[ref]['battery_ok'] = value
 | 
					                recorddb[ref]['battery_ok'] = value
 | 
				
			||||||
    
 | 
					    
 | 
				
			||||||
        if len(measures) > 0:
 | 
					        if measuresnb > 0:
 | 
				
			||||||
            recorddb[ref]["lastsend"] = currentts
 | 
					            recorddb[ref]["lastsend"] = currentts
 | 
				
			||||||
            #print(measures)
 | 
					            #print(measures)
 | 
				
			||||||
            try:
 | 
					            try:
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
							
								
								
									
										84
									
								
								src/main.ino
								
								
								
								
							
							
						
						
									
										84
									
								
								src/main.ino
								
								
								
								
							| 
						 | 
					@ -1,6 +1,6 @@
 | 
				
			||||||
#include <ArduinoJson.h>
 | 
					#include <ArduinoJson.h>
 | 
				
			||||||
#include <rtl_433_ESP.h>
 | 
					#include <rtl_433_ESP.h>
 | 
				
			||||||
#include <RCSwitch.h>
 | 
					//#include <RCSwitch.h>
 | 
				
			||||||
#include <Wire.h>
 | 
					#include <Wire.h>
 | 
				
			||||||
#include <BME280I2C.h>
 | 
					#include <BME280I2C.h>
 | 
				
			||||||
#include <EnvironmentCalculations.h>
 | 
					#include <EnvironmentCalculations.h>
 | 
				
			||||||
| 
						 | 
					@ -12,21 +12,23 @@
 | 
				
			||||||
 | 
					
 | 
				
			||||||
#define _DICT_PACK_STRUCTURES
 | 
					#define _DICT_PACK_STRUCTURES
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					#ifndef LED_BUILTIN
 | 
				
			||||||
 | 
					  #define LED_BUILTIN 12
 | 
				
			||||||
 | 
					#endif
 | 
				
			||||||
#define LED LED_BUILTIN
 | 
					#define LED LED_BUILTIN
 | 
				
			||||||
 | 
					
 | 
				
			||||||
#define RCSWITCH_PIN 43
 | 
					#define RCSWITCH_PIN 43
 | 
				
			||||||
 | 
					
 | 
				
			||||||
//CC1101 radiotx = RADIO_LIB_MODULE;
 | 
					CC1101 radiotx = RADIO_LIB_MODULE;
 | 
				
			||||||
RCSwitch mySwitch = RCSwitch();
 | 
					//RCSwitch mySwitch = RCSwitch();
 | 
				
			||||||
 | 
					
 | 
				
			||||||
#ifndef RF_MODULE_FREQUENCY
 | 
					 | 
				
			||||||
#  define RF_MODULE_FREQUENCY 433.92
 | 
					 | 
				
			||||||
#endif
 | 
					 | 
				
			||||||
 | 
					
 | 
				
			||||||
#define JSON_MSG_BUFFER 512
 | 
					#define JSON_MSG_BUFFER 512
 | 
				
			||||||
#define MINDELAY 10L
 | 
					#define MINDELAY 10L
 | 
				
			||||||
#define ALTITUDE 150.0
 | 
					//#define ALTITUDE 150.0
 | 
				
			||||||
#define DELAYLOCALSENSORS 30L
 | 
					#define ALTITUDE 210.0
 | 
				
			||||||
 | 
					#define DELAYLOCALSENSORS 60L
 | 
				
			||||||
 | 
					//#define DELAYKAKUSEND 750L
 | 
				
			||||||
 | 
					
 | 
				
			||||||
Dictionary<String, unsigned long> d1;
 | 
					Dictionary<String, unsigned long> d1;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
| 
						 | 
					@ -38,6 +40,10 @@ BME280I2C bme;
 | 
				
			||||||
bool sensors_enabled;
 | 
					bool sensors_enabled;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
int count = 0;
 | 
					int count = 0;
 | 
				
			||||||
 | 
					unsigned long lastrcv = 0;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					//unsigned long kakucode = 0;
 | 
				
			||||||
 | 
					//bool kakucmd = false;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
uint32_t lastts_localsensors = 0;
 | 
					uint32_t lastts_localsensors = 0;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
| 
						 | 
					@ -45,16 +51,22 @@ void rtl_433_Callback(char* message) {
 | 
				
			||||||
  //Serial.println("RTL433 Callback");
 | 
					  //Serial.println("RTL433 Callback");
 | 
				
			||||||
  JsonDocument jsonDocument;
 | 
					  JsonDocument jsonDocument;
 | 
				
			||||||
  deserializeJson(jsonDocument,message);
 | 
					  deserializeJson(jsonDocument,message);
 | 
				
			||||||
 | 
					  //logJsonAll(jsonDocument);
 | 
				
			||||||
  logJson(jsonDocument);
 | 
					  logJson(jsonDocument);
 | 
				
			||||||
  count++;
 | 
					  count++;
 | 
				
			||||||
 | 
					  lastrcv = millis();
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
JsonDocument analyzeTH_type1(JsonArray payloadrh) {
 | 
					JsonDocument analyzeTH_type1(JsonArray payloadrh) {
 | 
				
			||||||
  JsonDocument doc;
 | 
					  JsonDocument doc;
 | 
				
			||||||
  doc["moisture"] = payloadrh[5].as<int>();
 | 
					  doc["battery_ok"] = payloadrh[0].as<unsigned char>() & 0b00000001;
 | 
				
			||||||
  int16_t payloadtemp = payloadrh[4].as<unsigned char>();
 | 
					  int16_t payloadtemp = payloadrh[4].as<unsigned char>();
 | 
				
			||||||
  payloadtemp += payloadrh[3].as<unsigned char>() << 8;
 | 
					  payloadtemp += payloadrh[3].as<unsigned char>() << 8;
 | 
				
			||||||
  doc["temperature_C"] = payloadtemp / 100.0;
 | 
					  doc["temperature_C"] = payloadtemp / 100.0;
 | 
				
			||||||
 | 
					  //doc["moisture"] = payloadrh[5].as<int>();
 | 
				
			||||||
 | 
					  uint16_t payloadmoisture = payloadrh[6].as<unsigned char>();
 | 
				
			||||||
 | 
					  payloadmoisture += payloadrh[5].as<unsigned char>() << 8;
 | 
				
			||||||
 | 
					  doc["moisture"] = payloadmoisture;
 | 
				
			||||||
  doc["battery_ok"] = payloadrh[0].as<unsigned char>() & 0b00000001;
 | 
					  doc["battery_ok"] = payloadrh[0].as<unsigned char>() & 0b00000001;
 | 
				
			||||||
  uint16_t payloadbat = payloadrh[2].as<unsigned char>();
 | 
					  uint16_t payloadbat = payloadrh[2].as<unsigned char>();
 | 
				
			||||||
  payloadbat += payloadrh[1].as<unsigned char>() << 8;
 | 
					  payloadbat += payloadrh[1].as<unsigned char>() << 8;
 | 
				
			||||||
| 
						 | 
					@ -63,6 +75,16 @@ JsonDocument analyzeTH_type1(JsonArray payloadrh) {
 | 
				
			||||||
  return doc;
 | 
					  return doc;
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					JsonDocument analyzeTH_type2(JsonArray payloadrh) {
 | 
				
			||||||
 | 
					  JsonDocument doc;
 | 
				
			||||||
 | 
					  int16_t payloadtemp = payloadrh[2].as<unsigned char>();
 | 
				
			||||||
 | 
					  payloadtemp += payloadrh[1].as<unsigned char>() << 8;
 | 
				
			||||||
 | 
					  doc["temperature_C"] = payloadtemp / 100.0;
 | 
				
			||||||
 | 
					  uint8_t payloadhumidity = payloadrh[3].as<unsigned char>();
 | 
				
			||||||
 | 
					  doc["humidity"] = payloadhumidity;
 | 
				
			||||||
 | 
					  return doc;
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
void logJson(JsonDocument jsondata) {
 | 
					void logJson(JsonDocument jsondata) {
 | 
				
			||||||
  if(jsondata["model"].is<String>())
 | 
					  if(jsondata["model"].is<String>())
 | 
				
			||||||
  {
 | 
					  {
 | 
				
			||||||
| 
						 | 
					@ -76,7 +98,7 @@ void logJson(JsonDocument jsondata) {
 | 
				
			||||||
      if(jsondata["model"].is<String>() && jsondata["model"] == "RadioHead-ASK") {
 | 
					      if(jsondata["model"].is<String>() && jsondata["model"] == "RadioHead-ASK") {
 | 
				
			||||||
        JsonArray payloadrh = jsondata["payload"];
 | 
					        JsonArray payloadrh = jsondata["payload"];
 | 
				
			||||||
        bool treatrh = 0;
 | 
					        bool treatrh = 0;
 | 
				
			||||||
        if(jsondata["len"].as<int>() == 6  && ((payloadrh[0].as<unsigned char>() & 0b00010000 ) > 0)) {
 | 
					        if(jsondata["len"].as<int>() == 7  && ((payloadrh[0].as<unsigned char>() & 0b00010000 ) > 0)) {
 | 
				
			||||||
          treatrh = true;
 | 
					          treatrh = true;
 | 
				
			||||||
          //Serial.println("Analyse RH Payload");
 | 
					          //Serial.println("Analyse RH Payload");
 | 
				
			||||||
          JsonDocument adoc = analyzeTH_type1(payloadrh);
 | 
					          JsonDocument adoc = analyzeTH_type1(payloadrh);
 | 
				
			||||||
| 
						 | 
					@ -85,6 +107,11 @@ void logJson(JsonDocument jsondata) {
 | 
				
			||||||
          jsondata["battery_V"] = adoc["battery_V"];
 | 
					          jsondata["battery_V"] = adoc["battery_V"];
 | 
				
			||||||
          jsondata["battery_percent"] = adoc["battery_percent"];
 | 
					          jsondata["battery_percent"] = adoc["battery_percent"];
 | 
				
			||||||
          jsondata["temperature_C"] = adoc["temperature_C"];
 | 
					          jsondata["temperature_C"] = adoc["temperature_C"];
 | 
				
			||||||
 | 
					        } else if(jsondata["len"].as<int>() == 4  && ((payloadrh[0].as<unsigned char>() & 0b00100000 ) > 0)) {
 | 
				
			||||||
 | 
					          treatrh = true;
 | 
				
			||||||
 | 
					          JsonDocument adoc = analyzeTH_type2(payloadrh);
 | 
				
			||||||
 | 
					          jsondata["temperature_C"] = adoc["temperature_C"];
 | 
				
			||||||
 | 
					          jsondata["humidity"] = adoc["humidity"];
 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
        if(treatrh == true) {
 | 
					        if(treatrh == true) {
 | 
				
			||||||
          jsondata.remove("from");
 | 
					          jsondata.remove("from");
 | 
				
			||||||
| 
						 | 
					@ -149,6 +176,7 @@ void logJsonRH(JsonDocument jsondata) {
 | 
				
			||||||
      //Serial.println();
 | 
					      //Serial.println();
 | 
				
			||||||
      //ledblink();
 | 
					      //ledblink();
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					*/
 | 
				
			||||||
 | 
					
 | 
				
			||||||
void logJsonAll(JsonDocument jsondata) {
 | 
					void logJsonAll(JsonDocument jsondata) {
 | 
				
			||||||
 // Serial.println(count);
 | 
					 // Serial.println(count);
 | 
				
			||||||
| 
						 | 
					@ -162,7 +190,7 @@ void logJsonAll(JsonDocument jsondata) {
 | 
				
			||||||
      Serial.println(JSONmessageBuffer);
 | 
					      Serial.println(JSONmessageBuffer);
 | 
				
			||||||
      //ledblink();
 | 
					      //ledblink();
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
*/
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
void sendBME280() {
 | 
					void sendBME280() {
 | 
				
			||||||
  JsonDocument jsonDocument;
 | 
					  JsonDocument jsonDocument;
 | 
				
			||||||
| 
						 | 
					@ -203,14 +231,29 @@ void ledblink() {
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
void setup() {
 | 
					void setup() {
 | 
				
			||||||
  Serial.setTxBufferSize(512);
 | 
					  //Serial.setTxBufferSize(512);
 | 
				
			||||||
  //Serial.setTxTimeoutMs(100);
 | 
					  //Serial.setTxTimeoutMs(100);
 | 
				
			||||||
  Serial.begin(115200);
 | 
					  Serial.begin(115200);
 | 
				
			||||||
  delay(1000);
 | 
					  delay(10000);
 | 
				
			||||||
  //for (int i=0 ; i<10; i++) {
 | 
					  //for (int i=0 ; i<10; i++) {
 | 
				
			||||||
  //     Serial.print("Hello");
 | 
					  //     Serial.print("Hello");
 | 
				
			||||||
  //    delay(1000);
 | 
					  //    delay(1000);
 | 
				
			||||||
  //}
 | 
					  //}
 | 
				
			||||||
 | 
					  /*Serial.print("MISO ");
 | 
				
			||||||
 | 
					  Serial.println(MISO);
 | 
				
			||||||
 | 
					  Serial.print("MOSI ");
 | 
				
			||||||
 | 
					  Serial.println(MOSI);
 | 
				
			||||||
 | 
					  Serial.print("SS ");
 | 
				
			||||||
 | 
					  Serial.println(SS);
 | 
				
			||||||
 | 
					  Serial.print("SCK ");
 | 
				
			||||||
 | 
					  Serial.println(SCK);
 | 
				
			||||||
 | 
					  */
 | 
				
			||||||
 | 
					  /*SPI.begin(SCK, MISO, MOSI, SS);
 | 
				
			||||||
 | 
					  SPI.setFrequency(4000000);*/
 | 
				
			||||||
 | 
					  SPI.setFrequency(4000000);
 | 
				
			||||||
 | 
					  Serial.printf("SPI.begin(SCK=%d, MISO=%d, MOSI=%d, CS=%d)\n", SCK, MISO, MOSI, SS);
 | 
				
			||||||
 | 
					  Serial.print("RF_MODULE_RECEIVER_GPIO ");
 | 
				
			||||||
 | 
					  Serial.println(RF_MODULE_RECEIVER_GPIO);
 | 
				
			||||||
 /* if(SS != 21 || MOSI != 20 || MISO != 10 || SCK != 7)
 | 
					 /* if(SS != 21 || MOSI != 20 || MISO != 10 || SCK != 7)
 | 
				
			||||||
  {
 | 
					  {
 | 
				
			||||||
    for ( ; ; ) {
 | 
					    for ( ; ; ) {
 | 
				
			||||||
| 
						 | 
					@ -235,10 +278,17 @@ void setup() {
 | 
				
			||||||
 | 
					
 | 
				
			||||||
void loop() {
 | 
					void loop() {
 | 
				
			||||||
  rf.loop();
 | 
					  rf.loop();
 | 
				
			||||||
  if(sensors_enabled == true && (millis() > (lastts_localsensors + (DELAYLOCALSENSORS*1000)) || lastts_localsensors > millis())) {
 | 
					  if(sensors_enabled == true && (millis() > (lastts_localsensors + (DELAYLOCALSENSORS*1000) + random(0, 5000)) || lastts_localsensors > millis())) {
 | 
				
			||||||
    lastts_localsensors = millis();
 | 
					    lastts_localsensors = millis();
 | 
				
			||||||
    sendBME280();
 | 
					    sendBME280();
 | 
				
			||||||
  }
 | 
					  }
 | 
				
			||||||
 | 
					  /*if(kakucode > 0 && (millis() > (lastrcv + DELAYKAKUSEND) || lastrcv > millis())) {
 | 
				
			||||||
 | 
					    rf.disableReceiver();
 | 
				
			||||||
 | 
					    radiotx.SPIsendCommand(RADIOLIB_CC1101_CMD_TX);
 | 
				
			||||||
 | 
					    radiotx.SPIsendCommand(RADIOLIB_CC1101_CMD_RX);
 | 
				
			||||||
 | 
					    rf.enableReceiver();
 | 
				
			||||||
 | 
					    kakucode = 0;
 | 
				
			||||||
 | 
					  }*/
 | 
				
			||||||
  if (Serial.available()) 
 | 
					  if (Serial.available()) 
 | 
				
			||||||
  {
 | 
					  {
 | 
				
			||||||
    // Read the JSON document from the "link" serial port
 | 
					    // Read the JSON document from the "link" serial port
 | 
				
			||||||
| 
						 | 
					@ -257,10 +307,10 @@ void loop() {
 | 
				
			||||||
	 //rf.disableReceiver();
 | 
						 //rf.disableReceiver();
 | 
				
			||||||
	 //radiotx.SPIsendCommand(RADIOLIB_CC1101_CMD_TX);
 | 
						 //radiotx.SPIsendCommand(RADIOLIB_CC1101_CMD_TX);
 | 
				
			||||||
         //mySwitch.enableTransmit(RF_MODULE_GDO0);
 | 
					         //mySwitch.enableTransmit(RF_MODULE_GDO0);
 | 
				
			||||||
         mySwitch.enableTransmit(RCSWITCH_PIN);
 | 
					         //mySwitch.enableTransmit(RCSWITCH_PIN);
 | 
				
			||||||
         //mySwitch.setRepeatTransmit(8);
 | 
					         //mySwitch.setRepeatTransmit(8);
 | 
				
			||||||
         mySwitch.setRepeatTransmit(5);
 | 
					         //mySwitch.setRepeatTransmit(5);
 | 
				
			||||||
         mySwitch.send(doc["value"].as<uint32_t>(), 24);
 | 
					         //mySwitch.send(doc["value"].as<uint32_t>(), 24);
 | 
				
			||||||
         //mySwitch.disableTransmit();
 | 
					         //mySwitch.disableTransmit();
 | 
				
			||||||
	 //radiotx.SPIsendCommand(RADIOLIB_CC1101_CMD_RX);
 | 
						 //radiotx.SPIsendCommand(RADIOLIB_CC1101_CMD_RX);
 | 
				
			||||||
	 //rf.enableReceiver();
 | 
						 //rf.enableReceiver();
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
		Loading…
	
		Reference in New Issue