espnowSimple 1
Loading...
Searching...
No Matches
cansat24read.ino
Go to the documentation of this file.
1/*
2* CANSAT NeXT kit base example
3*/
4
5/* cansatdk
6*
7* cansatdk.cpp
8* ----------------------------------------------------------------------------
9* "THE BEER-WARE LICENSE":
10* <jensd@jensd.dk/jdn@es.aau.dk> wrote this file. As long as you retain this notice you
11* can do whatever you want with this stuff. If we meet some day, and you think
12* this stuff is worth it, you can buy me a beer in return.
13* Jens Dalsgaard Nielsen April 2024
14* ----------------------------------------------------------------------------
15* be inspired here : https://randomnerdtutorials.com/get-change-esp32-esp8266-mac-address-arduino/
16* and see http://jensd.dk/doc/esp32
17*
18*
19* This example shows how data can be sent from the satellite to the groundstation.
20* The same functions work the other way around as well, and can be used to send data to the satellite from the groundstation.
21* Caution - You should always have an antenna in a radio system before transmitting anything. Make sure the antenna is plugged in before sending data via the radio.
22*
23* Links
24*
25* http://cansat.fi
26* https://dronebotworkshop.com/esp-now/
27*
28* http://jensd.dk/doc/cansat/cansatdk this code can be found here
29*/
30
31#include "CanSatNeXT.h"
32#include "cansatdk.h"
33
34#define NETID 72
35
36
37// 2 for base 5 for cansat NeXT
38#define BASELED 5
39
40void setup() {
41
42 Serial.begin(115200);
43 pinMode(BASELED, OUTPUT);
44
45 // Initialize CanSatNeXT systems.
46 // Calling this function with an address as a parameter enables the radio.
47 // The address is shared by both the transmitter and receiver.
48 GroundStationInit(NETID);
49}
50
51
52/*
53cansatDK datapkg
54
55typedef struct cansatdkPkg{
56float accX,accY,accZ,
57float gyroX,gyroY,gyroZ;
58float pressure;
59float temperature;
60int seqNr;
61uint8_t macAddr[6];
62bool SDcardAvailable;
63} cansatdkPkg;
64*/
65
66cansatdkPkg dataPkg;
67
68
69void printMAC(uint8_t *mac)
70{
71 for (int i = 0; i < 6; i++) {
72 Serial.print(" Ox");
73 if (mac[i] <= 9)
74 Serial.print("0");
75 Serial.print(mac[i], HEX);
76 }
77 Serial.println();
78}
79
80
81void displayData(cansatdkPkg *data)
82{
83 Serial.print("\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\nNodeID: "); // kan fjernes
84 printMAC(data->macAddr);
85 Serial.println("nr " + (String)(data->seqNr));
86 Serial.println("acc " + (String)(data->accX) + " " + (String)(data->accY) + " " + (String)(data->accZ));
87 Serial.println("gyr " + (String)(data->gyroX) + " " + (String)(data->gyroY) + " " + (String)(data->gyroZ));
88 Serial.println("prs " + (String(data->pressure)));
89 Serial.println("tmp " + (String(data->temperature)));
90}
91
92void onBinaryDataReceived(const uint8_t *data, int len){
93 memcpy(&dataPkg, data, sizeof(dataPkg));
94 Serial.println(dataPkg.seqNr);
96}
97
98
99void loop() {
100}
cansatdkPkg dataPkg
#define BASELED
void setup()
#define NETID
void printMAC(uint8_t *mac)
void onBinaryDataReceived(const uint8_t *data, int len)
void displayData(cansatdkPkg *data)
void loop()