Wenn du dir nicht sicher bist, in welchem der anderen Foren du die Frage stellen sollst, dann bist du hier im Forum für allgemeine Fragen sicher richtig.
Kann mir jemand diese Skript in ein Python Skript umwandeln denn ich kenne mich mict keinen anderen Programmiesprachen aus.Das ist das Skript für den Light Level Sensor - LM393(https://www.mysensors.org/build/light-lm393), zu dem ich leider keine Anleitung für Phython finden kann.
* REVISION HISTORY
* Version 1.0 - Henrik EKblad
*
* DESCRIPTION
* Example sketch showing how to measure light level using a LM393 photo-resistor
* http://www.mysensors.org/build/light
*/
// Enable debug prints to serial monitor
#define MY_DEBUG
// Enable and select radio type attached
#define MY_RADIO_RF24
//#define MY_RADIO_NRF5_ESB
//#define MY_RADIO_RFM69
//#define MY_RADIO_RFM95
#include <MySensors.h>
#define CHILD_ID_LIGHT 0
#define LIGHT_SENSOR_ANALOG_PIN 0
uint32_t SLEEP_TIME = 30000; // Sleep time between reads (in milliseconds)
MyMessage msg(CHILD_ID_LIGHT, V_LIGHT_LEVEL);
int lastLightLevel;
void presentation()
{
// Send the sketch version information to the gateway and Controller
sendSketchInfo("Light Sensor", "1.0");
// Register all sensors to gateway (they will be created as child devices)
present(CHILD_ID_LIGHT, S_LIGHT_LEVEL);
}
void loop()
{
int16_t lightLevel = (1023-analogRead(LIGHT_SENSOR_ANALOG_PIN))/10.23;
Serial.println(lightLevel);
if (lightLevel != lastLightLevel) {
send(msg.set(lightLevel));
lastLightLevel = lightLevel;
}
sleep(SLEEP_TIME);
}
#!/usr/bin/env python3
from time import sleep
from MySensors import (
analog_read, MyMessage, present, send, send_sketch_info, Serial,
S_LIGHT_LEVEL, V_LIGHT_LEVEL
)
CHILD_ID_LIGHT = 0
LIGHT_SENSOR_ANALOG_PIN = 1
SLEEP_TIME = 30
def main():
# Send the sketch version information to the gateway and controller.
send_sketch_info('Light Sensor', '1.0')
# Register all sensors to gateway (they will be created as child devices).
present(CHILD_ID_LIGHT, S_LIGHT_LEVEL)
message = MyMessage(CHILD_ID_LIGHT, V_LIGHT_LEVEL)
previous_light_level = None
while True:
light_level = (1023 - analog_read(LIGHT_SENSOR_ANALOG_PIN)) / 10.23
Serial.println(light_level)
if light_level != previous_light_level:
send(message.set(light_level))
previous_light_level = light_level
sleep(SLEEP_TIME)
if __name__ == '__main__':
main()
Jetzt musst Du nur noch ein `MySensors`-Modul irgendwo her bekommen und Python auf den Arduino…
“Most people find the concept of programming obvious, but the doing impossible.” — Alan J. Perlis