Hallo zusammen,
ich möchte mich kurz vorstellen:
1971 geboren,
1987 Kommunikationselektroniker gelernt,
abgebrochenes Studium Nachrichtentechnik =(
seit dem Betriebselektriker, Schwerpunkt Fehlersuche mit S7 bei einem Automobilzulieferer,
seit 2 Wochen Besitzer einer Raspberry Pi 3.
Ich weiß schon das mein Betriebssystem linux ist,
das "sudo" die Rechte von "root" ersetzt,
und das "nano" ein Texteditor ist.
... und das war gar nicht so einfach raus zu finden!
Mein Ziel ist es das die Raspi ein paar Steuerungsaufgaben in meinem Haus automatisiert. Das ganze soll unter c++ geschehen. Ich hab da zwar keine Ahnung von, aber auf der ein oder anderen Seite im Internet wird die Sprache empfohlen.
Einzelne gpios kann ich auch schon ein- und ausschalten.
Ich hab alle möglichen Sachen installiert um auf den i2c-Bus zuzugreifen.
Über einen Level-Shifter habe ich zwei PCF8574 (IO-Expander) sowie einen PCF8591 angeschlossen.
Bei dem Befehl:
kommt tatsächlich als Antwort:
0 1 2 3 4 5 6 7 8 9 a b c d e f
00: -- -- -- -- -- -- -- -- -- -- -- -- --
10: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
20: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
30: -- -- -- -- -- -- -- -- 38 39 -- -- -- -- -- --
40: -- -- -- -- -- -- -- -- 48 -- -- -- -- -- -- --
50: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
60: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
70: -- -- -- -- -- -- -- --
da bin ich schon ein bisschen stolz auf mich!
Jetzt hab ich im Netz das Programm pcf8591.cpp gefunden:
#include <iostream>
#include <wiringPi.h>
#include <wiringPiI2C.h>
using namespace std;
int readInput(int fd, int reg)
{
wiringPiI2CReadReg8(fd, reg);
return wiringPiI2CReadReg8(fd, reg);
}
int main()
{
wiringPiSetupGpio();
int dacModule = wiringPiI2CSetup(0x48);
if (dacModule < 0)
{
cout << "I2C Setup Error" << endl;
return 0;
}
int i;
int A[4] = {0, 0, 0, 0};
int A_Reg[4] = {0x40, 0x41, 0x42, 0x43};
while (1)
{
for (i=0;i<4;i++) A[i] = readInput(dacModule, A_Reg[i]);
wiringPiI2CWriteReg8(dacModule, 0x40, (A[0]+A[1]+A[2]+A[3])/4);
cout << endl;
for (i=0;i<4;i++) cout << i << " : " << A[i] << endl;
delay(500);
}
return 0;
}
Alles anzeigen
Wenn ich jetzt:
eingebe, dann kommt
/tmp/cc5ZLyXt.o: In function `readInput(int, int)':
pcf8591.cpp:(.text+0x1c): undefined reference to `wiringPiI2CReadReg8'
pcf8591.cpp:(.text+0x28): undefined reference to `wiringPiI2CReadReg8'
/tmp/cc5ZLyXt.o: In function `main':
pcf8591.cpp:(.text+0x48): undefined reference to `wiringPiSetupGpio'
pcf8591.cpp:(.text+0x50): undefined reference to `wiringPiI2CSetup'
pcf8591.cpp:(.text+0x154): undefined reference to `wiringPiI2CWriteReg8'
pcf8591.cpp:(.text+0x1dc): undefined reference to `delay'
collect2: error: ld returned 1 exit status
pi@raspberrypi:~ $
als Antwort.
Muss ich da noch irgend was installieren? Ist das Programm nicht richtig (für mich)? Die Adresse 48 stimmt......
Danke für Eure Hilfe,
Gruss,
Achim Meyer