• Benvenuti su RaspberryItaly!
Benvenuto ospite! Login Login con Facebook Registrati Login with Facebook


Valutazione discussione:
  • 0 voto(i) - 0 media
  • 1
  • 2
  • 3
  • 4
  • 5

[-]
Tags
dongle raspberry sim7600g e

Raspberry e SIM7600G DONGLE
#1
Buongiorno a tutti e .. Buon 2026

Ho un Raspberry pi 4 (8gb ram) e volevo connetterlo
a internet tramite la scheda SIM7600G Dongle per inviare
a un sito internet un semplice array di dati del tipo:
(esempio) data = "1,25.0,26.5,89.23"
Pensavo ad un invio a un form php che riceva i dati e poi li iserisca dove necessario.

Ho provato seguendo il manuale:
https://www.waveshare.com/wiki/SIM7600G-H_4G_DONGLE
ma al momento sono in alto mare.

Se qualcuno ha realizzato qualcosa di simile o ha utilizzato la scheda.
Ci sono altre soluzioni possibili?
Grazie

Questo è il codiceche uso per inviare il messaggio:

Codice:
#----------------------------------------
import serial
import time

#----------------------------------------
# Serial speed
# 75, 110, 150, 300, 600, 1200, 1800,
# 2400, 4800, 9600, 14400, 19200, 57600, 115200
ser = serial.Serial('/dev/myusb2', 19200, timeout=5, xonxoff = False, rtscts = False, bytesize = serial.EIGHTBITS, parity = serial.PARITY_NONE, stopbits = serial.STOPBITS_ONE)
ser.flushInput()

#----------------------------------------
def send_at(command, back, timeout):
    rec_buff = ''
    ser.write((command+'\r\n').encode())
    time.sleep(timeout)
    if ser.inWaiting():
        time.sleep(0.1 )
        rec_buff = ser.read(ser.inWaiting())
    if rec_buff != '':
        if back not in rec_buff.decode():
            print(command + ' ERROR')
            print(command + ' back:\t' + rec_buff.decode())
            return 0
        else:
            print(rec_buff.decode())
            return 1
    else:
        print(command + ' no responce')
        return 0

#----------------------------------------
def sendMessage(url, data):

    size = len(data.encode("utf8"))

    try:
        #print(url)
        #print(data)
        #print(size)

        # Check the registration status
        send_at('AT+CREG?', 'OK', 1)

        send_at('AT+HTTPTERM', 'OK', 1)
       
        # Initialize HTTP service
        send_at('AT+HTTPINIT', 'OK', 1)

        # Set the HTTP URL
        send_at('AT+HTTPPARA="URL",\"'+url+'\"', 'OK', 2)

        # Set size
        send_at('AT+HTTPREAD=0,\"'+size+'\"', '', 1)

        ser.write(data.encode())
        if 1 == send_at(b'\x1a'.decode(), 'OK', 5):
            print('send message successfully!')

        # Set up the HTTP action 0:READ 1:POST 2:HEAD
        send_at('AT+HTTPACTION=1', 'OK', 1)           
       
        # Do a HTTP read
        #send_at('AT+HTTPREAD', '', 1)             

        # Terminate the HTTP service
        send_at('AT+HTTPTERM', 'OK', 1)             

    except:
        if ser != None:
            ser.close()

#----------------------------------------
url  = "https://www.site_name.com/readData.php"
data = "8.00,3.00,5.00,882.00,52.00,66.00,16.00,37.00,438,55"
#----------------------------------------
sendMessage(url, data)

e questo è il file php che riceve in un file di log per vedere i dati:

Codice PHP:
<?php
file_put_contents
('read.log'print_r($_POSTtrue), FILE_APPEND);
?>
Risposta
  


Vai al forum:


Navigazione: 1 Ospite(i)
Forum con nuovi Post
Forum senza nuovi post
Forum bloccato
Forum Redirect